Check for exc existence before using

This commit is contained in:
Twangboy 2025-01-15 09:54:14 -07:00 committed by Daniel Wozniak
parent 65ba161cd8
commit a7806bc91a

View file

@ -834,18 +834,19 @@ def zip_(zip_file, sources, template=None, cwd=None, runas=None, zip64=False):
if runas:
os.seteuid(euid)
os.setegid(egid)
if exc is not None:
# Wait to raise the exception until euid/egid are restored to avoid
# permission errors in writing to minion log.
if exc == zipfile.LargeZipFile:
raise CommandExecutionError(
"Resulting zip file too large, would require ZIP64 support"
"which has not been enabled. Rerun command with zip64=True"
)
else:
raise CommandExecutionError(
f"Exception encountered creating zipfile: {exc}"
)
if "exc" in vars() or "exc" in globals():
if exc is not None:
# Wait to raise the exception until euid/egid are restored to avoid
# permission errors in writing to minion log.
if exc == zipfile.LargeZipFile:
raise CommandExecutionError(
"Resulting zip file too large, would require ZIP64 support"
"which has not been enabled. Rerun command with zip64=True"
)
else:
raise CommandExecutionError(
f"Exception encountered creating zipfile: {exc}"
)
return archived_files