Skip to content

Commit

Permalink
Further optimizing precache.
Browse files Browse the repository at this point in the history
  • Loading branch information
theypsilon committed Feb 11, 2025
1 parent 3489063 commit 2ade5a1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/downloader/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,17 @@ def is_folder(self, path: str) -> bool:

def precache_is_file_with_folders(self, folders: List[PathPackage], recheck: bool = False) -> None:
not_checked_folders = folders if recheck else self._shared_state.consult_not_checked_folders(folders)
for folder_pkg in not_checked_folders:
try:
self._shared_state.add_many_files([f.path for f in os.scandir(folder_pkg.full_path) if f.is_file()])
except FileNotFoundError:
continue
try:
self._shared_state.add_many_files([f.path for folder_pkg in not_checked_folders for f in os.scandir(folder_pkg.full_path) if f.is_file()])
except Exception as e:
self._logger.debug(e)
for folder_pkg in not_checked_folders:
try:
self._shared_state.add_many_files([f.path for f in os.scandir(folder_pkg.full_path) if f.is_file()])
except OSError:
continue
except Exception as e:
return

def read_file_contents(self, path: str) -> str:
full_path = self._path(path)
Expand Down

0 comments on commit 2ade5a1

Please sign in to comment.