[ROMM-3232] Fix content_hash not updated

This commit is contained in:
Georges-Antoine Assi
2026-04-07 21:48:51 -04:00
parent b36a8b0cdf
commit 6c88e098ba
2 changed files with 15 additions and 2 deletions

View File

@@ -508,8 +508,19 @@ async def update_save(
await fs_asset_handler.write_file(
file=saveFile, path=db_save.file_path, filename=db_save.file_name
)
scanned_save = await scan_save(
file_name=db_save.file_name,
user=request.user,
platform_fs_slug=db_save.rom.platform_fs_slug,
rom_id=db_save.rom_id,
emulator=db_save.emulator,
)
db_save = db_save_handler.update_save(
db_save.id, {"file_size_bytes": saveFile.size}
db_save.id,
{
"file_size_bytes": scanned_save.file_size_bytes,
"content_hash": scanned_save.content_hash,
},
)
if screenshotFile and screenshotFile.filename:

View File

@@ -2,6 +2,8 @@ import hashlib
import os
import zipfile
from anyio import open_file
from config import ASSETS_BASE_PATH
from logger.logger import log
from models.user import User
@@ -70,7 +72,7 @@ class FSAssetsHandler(FSHandler):
async def _compute_file_hash(self, file_path: str) -> str:
hash_obj = hashlib.md5(usedforsecurity=False)
async with await self.stream_file(file_path=file_path) as f:
async with await open_file(file_path, "rb") as f:
while chunk := await f.read(8192):
hash_obj.update(chunk)
return hash_obj.hexdigest()