1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Don't try to walk over files when building archive

This commit is contained in:
Ben Doherty 2016-06-01 08:29:28 -04:00 committed by Matt Clay
parent 42112060b5
commit 87c8a21d16

View file

@ -230,12 +230,14 @@ def main():
arcfile = tarfile.open(dest, 'w|' + compression)
for path in archive_paths:
if os.path.isdir(path):
basename = ''
# Prefix trees in the archive with their basename, unless specifically prevented with '.'
if os.path.isdir(path) and not path.endswith(os.sep + '.'):
if not path.endswith(os.sep + '.'):
basename = os.path.basename(path) + os.sep
# Recurse into directories
for dirpath, dirnames, filenames in os.walk(path, topdown=True):
for dirname in dirnames:
fullpath = dirpath + os.sep + dirname
@ -264,6 +266,13 @@ def main():
except Exception:
e = get_exception()
errors.append('Adding %s: %s' % (path, str(e)))
else:
if compression == 'zip':
arcfile.write(path, path[len(arcroot):])
else:
arcfile.add(path, path[len(arcroot):], recursive=False)
successes.append(path)
except Exception:
e = get_exception()