Skip to content

Commit

Permalink
Fix issues ruff warned about
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Sep 24, 2024
1 parent fe3ea1e commit 2a86caa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cozy/control/offline_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import signal
import sys
import traceback
from pathlib import Path

import gi

Expand All @@ -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

Expand Down

0 comments on commit 2a86caa

Please sign in to comment.