*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 2b770bc2 authored by Moser, Maximilian's avatar Moser, Maximilian
Browse files

Detect reuse of existing file keys in draft files

parent 10999e38
No related branches found
No related tags found
1 merge request!16Modernize the package
......@@ -339,7 +339,16 @@ def add_files(filepaths, pid, pid_type, user):
)
sys.exit(1)
# TODO: this fails if a file with the same name already exists
# check for existing duplicates
files = list(file_service.list_files(id_=recid, identity=identity).entries())
existing_file_keys = [e["key"] for e in files]
if any([k for k in keys if k in existing_file_keys]):
click.secho(
"aborting: reuse of existing file names detected", fg="yellow", err=True
)
sys.exit(1)
# if all went well so far, continue on
file_service.init_files(
id_=recid, identity=identity, data=[{"key": basename(fp)} for fp in paths]
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment