fix renaming issue

This commit is contained in:
dece 2022-09-03 20:21:51 +02:00
parent 1dbd6af201
commit 3e131d9f2e

View file

@ -126,10 +126,10 @@ def write_content(data: bytes, name: str = "", extension: str = ""):
os.chmod(output_file.name, 0o644)
file_name = output_file.name
if name:
new_file_name = os.path.join(os.path.dirname(file_name), name)
old_file_name = file_name
file_name = os.path.join(os.path.dirname(old_file_name), name)
try:
os.rename(file_name, name)
file_name = new_file_name
os.rename(old_file_name, file_name)
except OSError as exc:
print(f"Failed to give required name to the file: {exc}")
return None