Skip to content

Commit

Permalink
Fixing corrupt hash file case.
Browse files Browse the repository at this point in the history
  • Loading branch information
theypsilon committed Sep 9, 2023
1 parent af126d4 commit 8bee52d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/downloader/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
FILE_downloader_needs_reboot_after_linux_update = '/tmp/downloader_needs_reboot_after_linux_update'
FILE_mister_downloader_needs_reboot = '/tmp/MiSTer_downloader_needs_reboot'

# Hash exceptional cases
HASH_file_does_not_exist = 'file_does_not_exist'

# Storage Priority
STORAGE_PRIORITY_PREFER_SD = 'prefer_sd'
STORAGE_PRIORITY_PREFER_EXTERNAL = 'prefer_external'
Expand Down
8 changes: 6 additions & 2 deletions src/downloader/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from typing import List, Optional, Set, Dict, Any, Tuple, Union

from downloader.config import AllowDelete
from downloader.constants import K_ALLOW_DELETE, K_BASE_PATH
from downloader.constants import K_ALLOW_DELETE, K_BASE_PATH, HASH_file_does_not_exist
from downloader.logger import Logger, NoLogger
from downloader.other import ClosableValue
import zipfile
Expand Down Expand Up @@ -253,7 +253,11 @@ def copy_fast(self, source: str, target: str) -> None:
self._fs_cache.add_file(full_target)

def hash(self, path: str) -> str:
return hash_file(self._path(path))
try:
return hash_file(self._path(path))
except FileNotFoundError as e:
self._logger.debug(e)
return HASH_file_does_not_exist

def make_dirs(self, path: str) -> None:
self._makedirs(self._path(path))
Expand Down

0 comments on commit 8bee52d

Please sign in to comment.