move: log error in case cache file cannot be moved

This commit is contained in:
Peter Bieringer 2025-03-02 07:54:25 +01:00
parent 36e33ffee1
commit a2cd430f64

View file

@ -21,6 +21,7 @@ import os
from radicale import item as radicale_item from radicale import item as radicale_item
from radicale import pathutils, storage from radicale import pathutils, storage
from radicale.log import logger
from radicale.storage import multifilesystem from radicale.storage import multifilesystem
from radicale.storage.multifilesystem.base import StorageBase from radicale.storage.multifilesystem.base import StorageBase
@ -45,11 +46,15 @@ class StoragePartMove(StorageBase):
cache_folder = self._get_collection_cache_subfolder(item.collection._filesystem_path, ".Radicale.cache", "item") cache_folder = self._get_collection_cache_subfolder(item.collection._filesystem_path, ".Radicale.cache", "item")
to_cache_folder = self._get_collection_cache_subfolder(to_collection._filesystem_path, ".Radicale.cache", "item") to_cache_folder = self._get_collection_cache_subfolder(to_collection._filesystem_path, ".Radicale.cache", "item")
self._makedirs_synced(to_cache_folder) self._makedirs_synced(to_cache_folder)
move_from = os.path.join(cache_folder, item.href)
move_to = os.path.join(to_cache_folder, to_href)
try: try:
os.replace(os.path.join(cache_folder, item.href), os.replace(move_from, move_to)
os.path.join(to_cache_folder, to_href))
except FileNotFoundError: except FileNotFoundError:
pass pass
except OSError as e:
logger.error("Failed to move cache file %r => %r %s" % (move_from, move_to, e))
pass
else: else:
self._makedirs_synced(to_cache_folder) self._makedirs_synced(to_cache_folder)
if cache_folder != to_cache_folder: if cache_folder != to_cache_folder: