mirror of
https://gitea.psi.ch/APOG/acsmnode.git
synced 2025-06-26 19:41:12 +02:00
Implemented safe save feature so that existing file is not replaced, possibly leading to loss of flagging information.
This commit is contained in:
@ -31,9 +31,14 @@ def save_file(name, content):
|
|||||||
content_type, content_string = content.split(',')
|
content_type, content_string = content.split(',')
|
||||||
decoded = base64.b64decode(content_string)
|
decoded = base64.b64decode(content_string)
|
||||||
file_path = os.path.join(UPLOAD_DIRECTORY, name)
|
file_path = os.path.join(UPLOAD_DIRECTORY, name)
|
||||||
with open(file_path, "wb") as f:
|
if not os.path.exists(file_path):
|
||||||
f.write(decoded)
|
with open(file_path, "wb") as f:
|
||||||
return file_path
|
f.write(decoded)
|
||||||
|
print(f"File saved successfully at {file_path}")
|
||||||
|
return file_path
|
||||||
|
else:
|
||||||
|
print(f'File already exists at {file_path}.\nTo maintain the integrity of the existing file, it will not be overwritten.')
|
||||||
|
return file_path
|
||||||
|
|
||||||
def filter_flags_by_label(flags_dict, label):
|
def filter_flags_by_label(flags_dict, label):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user