mirror of
https://github.com/rommapp/romm.git
synced 2026-06-28 06:46:00 +00:00
SaveSync: use pathlib joins for asset content-hash paths
FSAssetsHandler.compute_content_hash and _compute_zip_hash were
building full paths via f"{self.base_path}/{file_path}". self.base_path
is already a pathlib.Path (resolved by FSHandler.__init__), so the
f-string forced it to str, hard-coded the separator, and re-parsed --
fine on Linux but a footgun if a caller ever sneaks a leading slash or
the path needs Path semantics elsewhere.
Switch both spots to self.base_path / file_path, which is what every
other FSHandler subclass in this module already does (e.g.
FSRomsHandler, FSResourcesHandler, FSSyncHandler all join Path objects
directly).
This commit is contained in:
@@ -132,7 +132,7 @@ class FSAssetsHandler(FSHandler):
|
||||
return hash_obj.hexdigest()
|
||||
|
||||
async def _compute_zip_hash(self, zip_path: str) -> str:
|
||||
with zipfile.ZipFile(f"{self.base_path}/{zip_path}", "r") as zf:
|
||||
with zipfile.ZipFile(self.base_path / zip_path, "r") as zf:
|
||||
file_hashes = []
|
||||
for name in sorted(zf.namelist()):
|
||||
if not name.endswith("/"):
|
||||
@@ -144,7 +144,7 @@ class FSAssetsHandler(FSHandler):
|
||||
|
||||
async def compute_content_hash(self, file_path: str) -> str | None:
|
||||
try:
|
||||
full_path = f"{self.base_path}/{file_path}"
|
||||
full_path = self.base_path / file_path
|
||||
if zipfile.is_zipfile(full_path):
|
||||
return await self._compute_zip_hash(file_path)
|
||||
return await self._compute_file_hash(file_path)
|
||||
|
||||
Reference in New Issue
Block a user