Skip to content

Commit

Permalink
make flake8 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
pbiering committed Dec 3, 2024
1 parent edd6d0a commit 24f5f9b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions radicale/storage/multifilesystem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ class Storage(
def __init__(self, configuration: config.Configuration) -> None:
super().__init__(configuration)
self._makedirs_synced(self._filesystem_folder)
logger.info("storage location: %r", self._filesystem_folder);
logger.info("storage cache subfolder usage for item: %s", self._use_cache_subfolder_for_item);
logger.info("storage location: %r", self._filesystem_folder)
logger.info("storage cache subfolder usage for item: %s", self._use_cache_subfolder_for_item)
2 changes: 1 addition & 1 deletion radicale/storage/multifilesystem/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _get_collection_root_folder(self) -> str:
return os.path.join(self._filesystem_folder, "collection-root")

def _get_collection_cache_folder(self, path, folder, subfolder) -> str:
if self._use_cache_subfolder_for_item == True and subfolder == "item":
if (self._use_cache_subfolder_for_item is True) and (subfolder == "item"):
path = path.replace(os.path.join(self._filesystem_folder, "collection-root"), os.path.join(self._filesystem_folder, "collection-cache"))
return os.path.join(path, folder, subfolder)

Expand Down
9 changes: 3 additions & 6 deletions radicale/storage/multifilesystem/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def _store_item_cache(self, href: str, item: radicale_item.Item,
if not cache_hash:
cache_hash = self._item_cache_hash(
item.serialize().encode(self._encoding))
cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path, ".Radicale.cache",
"item")
cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path, ".Radicale.cache", "item")
content = self._item_cache_content(item)
self._storage._makedirs_synced(cache_folder)
# Race: Other processes might have created and locked the file.
Expand All @@ -96,8 +95,7 @@ def _store_item_cache(self, href: str, item: radicale_item.Item,

def _load_item_cache(self, href: str, cache_hash: str
) -> Optional[CacheContent]:
cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path, ".Radicale.cache",
"item")
cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path, ".Radicale.cache", "item")
try:
with open(os.path.join(cache_folder, href), "rb") as f:
hash_, *remainder = pickle.load(f)
Expand All @@ -111,8 +109,7 @@ def _load_item_cache(self, href: str, cache_hash: str
return None

def _clean_item_cache(self) -> None:
cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path, ".Radicale.cache",
"item")
cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path, ".Radicale.cache", "item")
self._clean_cache(cache_folder, (
e.name for e in os.scandir(cache_folder) if not
os.path.isfile(os.path.join(self._filesystem_path, e.name))))
6 changes: 2 additions & 4 deletions radicale/storage/multifilesystem/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ def move(self, item: radicale_item.Item,
if item.collection._filesystem_path != to_collection._filesystem_path:
self._sync_directory(item.collection._filesystem_path)
# Move the item cache entry
cache_folder = self._get_collection_cache_folder(item.collection._filesystem_path,
".Radicale.cache", "item")
to_cache_folder = self._get_collection_cache_folder(to_collection._filesystem_path,
".Radicale.cache", "item")
cache_folder = self._get_collection_cache_folder(item.collection._filesystem_path, ".Radicale.cache", "item")
to_cache_folder = self._get_collection_cache_folder(to_collection._filesystem_path, ".Radicale.cache", "item")
self._makedirs_synced(to_cache_folder)
try:
os.replace(os.path.join(cache_folder, item.href),
Expand Down
3 changes: 1 addition & 2 deletions radicale/storage/multifilesystem/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def get_safe_free_hrefs(uid: str) -> Iterator[str]:
yield radicale_item.find_available_uid(
lambda href: not is_safe_free_href(href), suffix)

cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path,
".Radicale.cache", "item")
cache_folder = self._storage._get_collection_cache_folder(self._filesystem_path, ".Radicale.cache", "item")
self._storage._makedirs_synced(cache_folder)
for item in items:
uid = item.uid
Expand Down

0 comments on commit 24f5f9b

Please sign in to comment.