Skip to content

Commit a373183

Browse files
committed
Ignore backup files that have been deleted during backup
1 parent 3f7e83c commit a373183

1 file changed

Lines changed: 51 additions & 29 deletions

File tree

core/src/com/biglybt/core/backup/impl/BackupManagerImpl.java

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -795,48 +795,70 @@
795795
}
796796
}else{
797797

798-
if ( !FileUtil.copyFileWithDates( from_file, to_file )){
798+
boolean copied = false;
799+
800+
if ( FileUtil.copyFileWithDates( from_file, to_file )){
799801

802+
copied = true;
803+
804+
}else{
805+
806+
// retry
807+
800808
try{
801809
Thread.sleep( 5000 );
802810

803811
}catch( Throwable e ){
804812
}
805813

806-
if ( !FileUtil.copyFileWithDates( from_file, to_file )){
807-
808-
// a few exceptions here (e.g. dasu plugin has a 'lock' file that breaks things)
814+
if ( FileUtil.copyFileWithDates( from_file, to_file )){
815+
816+
copied = true;
817+
818+
}else{
809819

810-
String name = from_file.getName().toLowerCase( Locale.US );
820+
// possible that from_file has been deleted in the meantime (e.g. some config files are removed when empty
811821

812-
String full_path = from_file.getAbsolutePath().toLowerCase( Locale.US );
813-
814-
if ( name.startsWith( ".lock" ) ||
815-
name.startsWith( ".azlock" ) || // i2phelper
816-
name.startsWith( "lock" ) || // dasu
817-
name.equals( "stats.lck" ) || // advanced stats plugin
818-
name.endsWith( ".saving" ) || // intermediate file
819-
name.endsWith( ".gz" ) || // most likely not interesting
820-
name.endsWith( ".jar" ) || // easy to recover later
821-
name.endsWith( ".zip" ) || // most likely not interesting
822-
name.endsWith( ".dll" ) || // might be in use, no big deal
823-
name.endsWith( ".so" ) || // might be in use, no big deal
824-
FileUtil.containsPathSegment(from_file, "cache", false) || // caches can be in use, no big deal
825-
FileUtil.containsPathSegment(from_file, "azneti2phelper" + File.separator + "netdb", false ) || // troublesome i2p files
826-
FileUtil.containsPathSegment(from_file, "azneti2phelper" + File.separator + "peerprofiles", false ) || // troublesome i2p files
827-
full_path.endsWith( "aznettor" + File.separator + "data" + File.separator + "lock" ) // troublesome tor files
828-
){
829-
830-
return( new long[]{ total_files, total_copied });
822+
if ( from_file.exists()){
823+
824+
// a few exceptions here (e.g. dasu plugin has a 'lock' file that breaks things)
825+
826+
String name = from_file.getName().toLowerCase( Locale.US );
827+
828+
String full_path = from_file.getAbsolutePath().toLowerCase( Locale.US );
829+
830+
if ( name.startsWith( ".lock" ) ||
831+
name.startsWith( ".azlock" ) || // i2phelper
832+
name.startsWith( "lock" ) || // dasu
833+
name.equals( "stats.lck" ) || // advanced stats plugin
834+
name.endsWith( ".saving" ) || // intermediate file
835+
name.endsWith( ".gz" ) || // most likely not interesting
836+
name.endsWith( ".jar" ) || // easy to recover later
837+
name.endsWith( ".zip" ) || // most likely not interesting
838+
name.endsWith( ".dll" ) || // might be in use, no big deal
839+
name.endsWith( ".so" ) || // might be in use, no big deal
840+
FileUtil.containsPathSegment(from_file, "cache", false) || // caches can be in use, no big deal
841+
FileUtil.containsPathSegment(from_file, "azneti2phelper" + File.separator + "netdb", false ) || // troublesome i2p files
842+
FileUtil.containsPathSegment(from_file, "azneti2phelper" + File.separator + "peerprofiles", false ) || // troublesome i2p files
843+
full_path.endsWith( "aznettor" + File.separator + "data" + File.separator + "lock" ) // troublesome tor files
844+
){
845+
846+
// ignore the failure
847+
848+
}else{
849+
850+
throw( new Exception( "Failed to copy file '" + from_file + "'" ));
851+
}
831852
}
832-
833-
throw( new Exception( "Failed to copy file '" + from_file + "'" ));
834853
}
835854
}
836855

837-
total_files++;
838-
839-
total_copied = from_file.length();
856+
if ( copied ){
857+
858+
total_files++;
859+
860+
total_copied = to_file.length();
861+
}
840862
}
841863

842864
return( new long[]{ total_files, total_copied });

0 commit comments

Comments
 (0)