|
795 | 795 | } |
796 | 796 | }else{ |
797 | 797 |
|
798 | | - if ( !FileUtil.copyFileWithDates( from_file, to_file )){ |
| 798 | + boolean copied = false; |
| 799 | + |
| 800 | + if ( FileUtil.copyFileWithDates( from_file, to_file )){ |
799 | 801 |
|
| 802 | + copied = true; |
| 803 | + |
| 804 | + }else{ |
| 805 | + |
| 806 | + // retry |
| 807 | + |
800 | 808 | try{ |
801 | 809 | Thread.sleep( 5000 ); |
802 | 810 |
|
803 | 811 | }catch( Throwable e ){ |
804 | 812 | } |
805 | 813 |
|
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{ |
809 | 819 |
|
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 |
811 | 821 |
|
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 | + } |
831 | 852 | } |
832 | | - |
833 | | - throw( new Exception( "Failed to copy file '" + from_file + "'" )); |
834 | 853 | } |
835 | 854 | } |
836 | 855 |
|
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 | + } |
840 | 862 | } |
841 | 863 |
|
842 | 864 | return( new long[]{ total_files, total_copied }); |
|
0 commit comments