Name uploaded and downloaded files J-<id>.<ext>
Files added through the upload pipeline and Download to Library are renamed to their J-ID right after indexing, so every new library file is traceable by its identifier (scanned files keep their existing names). index_file now returns the created location so callers can rename it; the location record is updated to the new path.
This commit is contained in:
@@ -55,7 +55,8 @@ def complete_temp_upload(temp, download_url=None):
|
||||
except Exception:
|
||||
destination.unlink(missing_ok=True)
|
||||
raise
|
||||
item, _, _ = services.index_file(destination, folder)
|
||||
item, _, location, _ = services.index_file(destination, folder)
|
||||
services.rename_location_to_j_id(item, location)
|
||||
if temp.file:
|
||||
temp.file.delete(save=False)
|
||||
else:
|
||||
@@ -66,7 +67,8 @@ def complete_temp_upload(temp, download_url=None):
|
||||
)
|
||||
with temp.file.open("rb") as source, open(destination, "wb") as target:
|
||||
shutil.copyfileobj(source, target)
|
||||
item, _, _ = services.index_file(destination, folder)
|
||||
item, _, location, _ = services.index_file(destination, folder)
|
||||
services.rename_location_to_j_id(item, location)
|
||||
temp.file.delete(save=False)
|
||||
|
||||
temp.library_item = item
|
||||
|
||||
Reference in New Issue
Block a user