-
Notifications
You must be signed in to change notification settings - Fork 53
Remove getSiteFiles function to simplify and speed up the export process #1457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove getSiteFiles function to simplify and speed up the export process #1457
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for simplifying this and reducing the work required in the export process. It works as advertised. I have tested different exports, and I have not found any issues. I have also exported broken symlinks and no errors are returned. LGTM! ![]()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| ( fsPromises.readdir as jest.Mock ).mockResolvedValue( mockFiles ); | ||
|
|
||
| // Mock fsPromises.stat for canHandle method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about cleaning up these comments as they seem self-explanatory?
katinthehatsite
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functionality looks good and works as expected 👍
From what I understand, the logic that you are removing is now handled by:
private addWpContent(): void {
const categories = (
[ 'uploads', 'plugins', 'themes', 'muPlugins', 'fonts' ] as BackupContentsCategory[]
).filter( ( category ) => this.options.includes[ category ] );
this.emit( ExportEvents.WP_CONTENT_EXPORT_START );
for ( const category of categories ) {
const folderName = category === 'muPlugins' ? 'mu-plugins' : category;
const absolutePath = path.join( this.options.site.path, 'wp-content', folderName );
const archivePath = path.relative( this.options.site.path, absolutePath );
this.archive.directory( absolutePath, archivePath, ( entry ) => {
const fullArchivePath = path.join( archivePath, entry.name );
const isExcluded = this.pathsToExclude.some( ( pathToExclude ) =>
fullArchivePath.startsWith( path.normalize( pathToExclude ) )
);
if (
isExcluded ||
entry.name.includes( '.git' ) ||
entry.name.includes( 'node_modules' )
) {
return false;
}
return entry;
} );
this.emit( ExportEvents.WP_CONTENT_EXPORT_PROGRESS, { directory: absolutePath } );
}
this.emit( ExportEvents.WP_CONTENT_EXPORT_COMPLETE );
}
Is that right?
Great question @katinthehatsite! Let me chime in with an answer. That is absolutely right, before the related changes, this function depended on backupContent.wpcomSites, but after those changes, the |
Yes, reading all the files and saving that list structure was slowly replaced over time. And the last push was when we replaced archive.file with archive.directory on #1448 My assumption is that Antony added the list of files in memory, thinking about future use for it in the progress bar, but that never happened. |

Related issues
Proposed Changes
getBackupContentsandgetSiteFilesfunctions.Testing Instructions
npm startPre-merge Checklist