refactor: polling_observer

This commit is contained in:
wumode
2025-07-27 12:37:27 +08:00
parent 721648ffdf
commit 68c29d89c9
5 changed files with 69 additions and 47 deletions

View File

@@ -227,11 +227,13 @@ class StorageBase(metaclass=ABCMeta):
__snapshot_file(sub_file, current_depth + 1)
else:
# 记录文件的完整信息用于比对
files_info[_fileitm.path] = {
'size': _fileitm.size or 0,
'modify_time': getattr(_fileitm, 'modify_time', 0),
'type': _fileitm.type
}
if getattr(_fileitm, 'modify_time', 0) > last_snapshot_time:
files_info[_fileitm.path] = {
'size': _fileitm.size or 0,
'modify_time': getattr(_fileitm, 'modify_time', 0),
'type': _fileitm.type
}
except Exception as e:
logger.debug(f"Snapshot error for {_fileitm.path}: {e}")

View File

@@ -31,6 +31,8 @@ class Alist(StorageBase, metaclass=WeakSingleton):
"move": "移动",
}
snapshot_check_folder_modtime = settings.OPENLIST_SNAPSHOT_CHECK_FOLDER_MODTIME
def __init__(self):
super().__init__()
@@ -586,6 +588,9 @@ class Alist(StorageBase, metaclass=WeakSingleton):
data=f,
)
if resp is None:
logger.warn(f"【OpenList】请求上传文件 {path} 失败")
return None
if resp.status_code != 200:
logger.warn(f"【OpenList】请求上传文件 {path} 失败,状态码:{resp.status_code}")
return None