Browse code

--no-check-md5 should disable md5sum calculation, including preserved attributes

Fixes https://github.com/s3tools/s3cmd/issues/217

--no-check-md5 removes 'md5' from the cfg.sync_checks list. It does
not remove it from the cfg.preserve_attrs_list list. Therefore each
file's md5sum is calculated when generating the preserved attribute
header (which also includes username, groupname, size, obtained from
stat(), ...). The default for both sync and put is --preserve.

Therefore, to disable md5 generation completely, one needs to also use
--no-preserve.

Another option would be to have --no-check-md5 also remove 'md5' from
cfg.preserve_attrs_list. I had added 'md5' to the
cfg.preserve_attrs_list list in June 2012 (1.5.0-alpha time period)
when I added hardlink detection, so it's a relatively new change that
is causing md5sums to be calculated by default. This patch implements
this, --no-check-md5 now removes 'md5' from cfg.preserve_attrs_list.

Matt Domsch authored on 2014/01/11 00:07:51
Showing 1 changed files
... ...
@@ -2080,10 +2080,14 @@ def main():
2080 2080
     if options.check_md5 == False:
2081 2081
         try:
2082 2082
             cfg.sync_checks.remove("md5")
2083
+            cfg.preserve_attrs_list.remove("md5")
2083 2084
         except Exception:
2084 2085
             pass
2085
-    if options.check_md5 == True and cfg.sync_checks.count("md5") == 0:
2086
-        cfg.sync_checks.append("md5")
2086
+    if options.check_md5 == True:
2087
+        if cfg.sync_checks.count("md5") == 0:
2088
+            cfg.sync_checks.append("md5")
2089
+        if cfg.preserve_attrs_list.count("md5") == 0:
2090
+            cfg.preserve_attrs_list.append("md5")
2087 2091
 
2088 2092
     ## Update Config with other parameters
2089 2093
     for option in cfg.option_list():