Archiver: reduce set of archived files for auto-backup

Keep around only source files that are modified by KiCad;
other files can be re-generated.
This commit is contained in:
Jon Evans 2021-02-04 17:24:02 -05:00
parent 4657ca5d4f
commit 7a55dff566
3 changed files with 32 additions and 17 deletions

View File

@ -152,21 +152,32 @@ bool PROJECT_ARCHIVER::Unarchive( const wxString& aSrcFile, const wxString& aDes
bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFile,
REPORTER& aReporter, bool aVerbose )
REPORTER& aReporter, bool aVerbose, bool aIncludeExtraFiles )
{
// List of file extensions to save.
// List of file extensions that are always archived
static const wxChar* extensionList[] = {
wxT( "*.pro" ),
wxT( "*.kicad_pro" ),
wxT( "*.kicad_prl" ),
wxT( "*.sch" ), // Legacy schematic files
wxT( "*.kicad_sch" ), // Schematic files
wxT( "*.lib" ), wxT( "*.dcm" ), // Legacy schematic library files
wxT( "*.kicad_sym" ), // schematic library files
wxT( "*.cmp" ),
wxT( "*.brd" ), wxT( "*.kicad_pcb" ), // Brd files
wxT( "*.mod" ), wxT( "*.kicad_mod" ), // fp files
wxT( "*.kicad_sch" ),
wxT( "*.kicad_sym" ),
wxT( "*.kicad_pcb" ),
wxT( "*.kicad_mod" ),
wxT( "*.kicad_dru" ),
wxT( "*.kicad_wks" ),
wxT( "fp-lib-table" ),
wxT( "sym-lib-table" )
};
// List of additional file extensions that are only archived when aIncludeExtraFiles is true
static const wxChar* extraExtensionList[] = {
wxT( "*.pro" ),
wxT( "*.sch" ), // Legacy schematic files
wxT( "*.lib" ), wxT( "*.dcm" ), // Legacy schematic library files
wxT( "*.cmp" ),
wxT( "*.brd" ),
wxT( "*.mod" ),
wxT( "*.stp" ), wxT( "*.step" ), // 3d files
wxT( "*.wrl" ),
wxT( "*.gb?" ), wxT( "*.gbrjob" ), // Gerber files
wxT( "*.gko" ), wxT( "*.gm1" ),
wxT( "*.gm2" ), wxT( "*.g?" ),
@ -175,12 +186,9 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
wxT( "*.gt?" ),
wxT( "*.pos" ), wxT( "*.drl" ), wxT( "*.nc" ), wxT( "*.xnc" ), // Fab files
wxT( "*.d356" ), wxT( "*.rpt" ),
wxT( "*.stp" ), wxT( "*.step" ), // 3d files
wxT( "*.wrl" ),
wxT( "*.net" ), wxT( "*.py" ),
wxT( "*.pdf" ), wxT( "*.txt" ), wxT( "*.kicad_wks" ),
wxT( "fp-lib-table" ), wxT( "sym-lib-table" )
};
wxT( "*.pdf" ), wxT( "*.txt" )
};
bool success = true;
wxString msg;
@ -207,6 +215,12 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
for( unsigned ii = 0; ii < arrayDim( extensionList ); ii++ )
wxDir::GetAllFiles( aSrcDir, &files, extensionList[ii] );
if( aIncludeExtraFiles )
{
for( unsigned ii = 0; ii < arrayDim( extraExtensionList ); ii++ )
wxDir::GetAllFiles( aSrcDir, &files, extraExtensionList[ii] );
}
files.Sort();
unsigned long uncompressedBytes = 0;

View File

@ -41,10 +41,11 @@ public:
* @param aDestFile is the full path to the zip file to be created
* @param aReporter is used to report status
* @param aVerbose controls the verbosity of reported status messages
* @param aIncludeExtraFiles if true will archive legacy and output files
* @return true if the archive was created successfully
*/
bool Archive( const wxString& aSrcDir, const wxString& aDestFile, REPORTER& aReporter,
bool aVerbose = true );
bool aVerbose = true, bool aIncludeExtraFiles = false );
/**
* Extracts an archive of the current project over existing files

View File

@ -129,5 +129,5 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event )
PROJECT_ARCHIVER archiver;
archiver.Archive( currdirname, zipFile.GetFullPath(), reporter );
archiver.Archive( currdirname, zipFile.GetFullPath(), reporter, true, true );
}