Phase 2.9 complete

This commit is contained in:
2026-08-04 12:05:45 -05:00
parent b7b21ab5e0
commit a45b686f6c
7 changed files with 549 additions and 20 deletions
+18
View File
@@ -92,6 +92,24 @@ def move_file_index(file_index, new_stored_path, kind=None):
return file_index
def refresh_file_index(file_index):
"""Recompute size + md5 from the stored file. Needed after an in-place
rewrite (e.g. injection of animationframework metadata) so downloads keep
a correct Content-Length."""
if not file_index.stored_path or not default_storage.exists(file_index.stored_path):
return file_index
with default_storage.open(file_index.stored_path, 'rb') as src:
md5 = hashlib.md5()
size = 0
for chunk in iter(lambda: src.read(1024 * 1024), b''):
md5.update(chunk)
size += len(chunk)
file_index.size = size
file_index.md5 = md5.hexdigest()
file_index.save(update_fields=['size', 'md5'])
return file_index
def delete_file_index(file_index):
"""Remove an indexed file from disk and DB (safe no-op when None)."""
if file_index is None: