Browse code

* s3cmd: Don't crash when file disappears before checking MD5.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@457 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2010/12/23 21:34:09
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+2010-12-24  Michal Ludvig  <mludvig@logix.net.nz>
2
+
3
+	* s3cmd: Don't crash when file disappears before
4
+	  checking MD5.
5
+
1 6
 2010-12-09  Michal Ludvig  <mludvig@logix.net.nz>
2 7
 
3 8
 	* Released version 1.0.0-rc2
... ...
@@ -805,15 +805,23 @@ def _compare_filelists(src_list, dst_list, src_remote, dst_remote):
805 805
 			
806 806
 			if attribs_match and 'md5' in cfg.sync_checks:
807 807
 				## ... same size, check MD5
808
-				if src_remote == False and dst_remote == True:
809
-					src_md5 = Utils.hash_file_md5(src_list[file]['full_name'])
810
-					dst_md5 = dst_list[file]['md5']
811
-				elif src_remote == True and dst_remote == False:
812
-					src_md5 = src_list[file]['md5']
813
-					dst_md5 = Utils.hash_file_md5(dst_list[file]['full_name'])
814
-				elif src_remote == True and dst_remote == True:
815
-					src_md5 = src_list[file]['md5']
816
-					dst_md5 = dst_list[file]['md5']
808
+				try:
809
+					if src_remote == False and dst_remote == True:
810
+						src_md5 = Utils.hash_file_md5(src_list[file]['full_name'])
811
+						dst_md5 = dst_list[file]['md5']
812
+					elif src_remote == True and dst_remote == False:
813
+						src_md5 = src_list[file]['md5']
814
+						dst_md5 = Utils.hash_file_md5(dst_list[file]['full_name'])
815
+					elif src_remote == True and dst_remote == True:
816
+						src_md5 = src_list[file]['md5']
817
+						dst_md5 = dst_list[file]['md5']
818
+				except:
819
+					# MD5 sum verification failed - ignore that file altogether
820
+					debug(u"IGNR: %s (disappeared)" % (file))
821
+					warning(u"%s: file disappeared, ignoring." % (file))
822
+					del(src_list[file])
823
+					del(dst_list[file])
824
+					continue
817 825
 
818 826
 				if src_md5 != dst_md5:
819 827
 					## Checksums are different.