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:
2026-09-17 11:56:01 -05:00
parent d4f5df2e4e
commit bf00cf36a2
4 changed files with 29 additions and 6 deletions
+2 -1
View File
@@ -212,7 +212,7 @@ class DownloadToLibraryView(APIView):
destination = services.unique_destination(folder, name)
try:
services.download_file(url, destination)
item, _, _ = services.index_file(destination, folder)
item, _, location, _ = services.index_file(destination, folder)
except Exception as exc: # noqa: BLE001 - report download failures
destination.unlink(missing_ok=True)
return Response(
@@ -239,6 +239,7 @@ class DownloadToLibraryView(APIView):
if update_fields:
item.save(update_fields=update_fields + ["updated_at"])
services.rename_location_to_j_id(item, location)
return Response(
MediaItemSerializer(item, context={"request": request}).data,
status=status.HTTP_201_CREATED,