diff --git a/cozy/control/offline_cache.py b/cozy/control/offline_cache.py index e77e4887..10f8bacd 100644 --- a/cozy/control/offline_cache.py +++ b/cozy/control/offline_cache.py @@ -106,21 +106,21 @@ def remove(self, book: Book): def remove_all_for_storage(self, storage): for element in OfflineCacheModel.select().join(File).where( storage.path in OfflineCacheModel.original_file.path): - file_path = os.path.join(self.cache_dir, element.cached_file) + file_path = self.cache_dir / element.cached_file if file_path == self.cache_dir: continue - file = Gio.File.new_for_path(file_path) + file = Gio.File.new_for_path(str(file_path)) if file.query_exists(): file.delete() OfflineCacheModel.delete().where(storage.path in OfflineCacheModel.original_file.path).execute() - def get_cached_path(self, chapter: Chapter): + def get_cached_path(self, chapter: Chapter) -> Path: query = OfflineCacheModel.select().where(OfflineCacheModel.original_file == chapter.file_id, OfflineCacheModel.copied) if query.count() > 0: - return os.path.join(self.cache_dir, query.get().cached_file) + return self.cache_dir / query.get().cached_file else: return None diff --git a/main.py b/main.py index 9fd8d9ef..614eda15 100755 --- a/main.py +++ b/main.py @@ -26,7 +26,6 @@ import signal import sys import traceback -from pathlib import Path import gi @@ -37,7 +36,7 @@ gi.require_version("GstController", "1.0") gi.require_version("GstPbutils", "1.0") -from gi.repository import Gio, GLib +from gi.repository import Gio from cozy.control.application_directories import get_data_dir