From c776932ca360342a0a073ef7b8a78f7a56d774fa Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Mon, 12 Sep 2016 07:47:45 +0200 Subject: [PATCH] Don't add included files as arguments on the command line (#4626) This means we will have to unarchive the complete archive if a single change is found. Unfortunately we cannot fix this for `unzip`, the only hope is a pure-python reimplementation. This fixes problems reported in the comments of #3810 --- files/unarchive.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/files/unarchive.py b/files/unarchive.py index 7f5ab13b4c4..95bfe36238c 100644 --- a/files/unarchive.py +++ b/files/unarchive.py @@ -440,6 +440,7 @@ class ZipArchive(object): elif stat.S_ISREG(st.st_mode) and timestamp < st.st_mtime: # Add to excluded files, ignore other changes out += 'File %s is newer, excluding file\n' % path + self.excludes.append(path) continue else: if timestamp != st.st_mtime: @@ -545,12 +546,12 @@ class ZipArchive(object): cmd = [ self.cmd_path, '-o', self.src ] if self.opts: cmd.extend(self.opts) - if self.includes: + # NOTE: Including (changed) files as arguments is problematic (limits on command line/arguments) +# if self.includes: # NOTE: Command unzip has this strange behaviour where it expects quoted filenames to also be escaped - cmd.extend(map(shell_escape, self.includes)) - # We don't need to handle excluded files, since we simply do not include them -# if self.excludes: -# cmd.extend([ '-x' ] + self.excludes ]) +# cmd.extend(map(shell_escape, self.includes)) + if self.excludes: + cmd.extend([ '-x' ] + self.excludes) cmd.extend([ '-d', self.dest ]) rc, out, err = self.module.run_command(cmd) return dict(cmd=cmd, rc=rc, out=out, err=err)