P1: 功能修复

- v2 三处 self.format_file_size -> format_file_size(3 个端点不再必崩)
- requirements 加 bcrypt、移除未使用的 aiohttp
- verify_user 改用 bcrypt.checkpw(DB basic 登录恢复);SHA256 回退改自描述 PBKDF2,去掉明文接受
- config.py token 模式只在缺失时生成(不再每次 update 失效)
- docker/npm/go/apt/yum 镜像补 cache_enabled/cache_ttl 初始化(不再必 500)
- docker 镜像兼容 upstream_url 配置键
- 定时同步链路: 回调委托 sync_starter 并注入 _sync_manager;cron 逗号列表修复;星期偏移修复
- v2 同步方法与 v1 签名兼容;MirrorSyncManager 补 get_source_status/stop_all_tasks_for_source
This commit is contained in:
HYC Fixer
2026-08-30 12:22:27 +08:00
parent 2a899c411e
commit 084164296d
13 changed files with 2089 additions and 2018 deletions
+16 -10
View File
@@ -1020,7 +1020,7 @@ class APIv2(APIv1):
"path": rel_path,
"type": mime_type,
"size": size,
"size_formatted": self.format_file_size(size),
"size_formatted": format_file_size(size),
"modified": datetime.fromtimestamp(mtime).isoformat(),
"match_score": self._calculate_match_score(file_name, search_term, search_mode)
}
@@ -1222,7 +1222,7 @@ class APIv2(APIv1):
"total_files": total_files,
"total_dirs": total_dirs,
"total_size": total_size,
"total_size_formatted": self.format_file_size(total_size)
"total_size_formatted": format_file_size(total_size)
},
"file_types": dict(sorted(file_types.items(), key=lambda x: x[1], reverse=True)),
"size_distribution": size_distribution,
@@ -1238,7 +1238,7 @@ class APIv2(APIv1):
"largest_file": {
"name": largest_file[0] if largest_file else None,
"size": largest_file[1] if largest_file else None,
"size_formatted": self.format_file_size(largest_file[1]) if largest_file else None
"size_formatted": format_file_size(largest_file[1]) if largest_file else None
}
},
"updated": datetime.now().isoformat()
@@ -1263,7 +1263,7 @@ class APIv2(APIv1):
"path": filepath,
"name": os.path.basename(filepath),
"size": info.st_size,
"size_formatted": self.format_file_size(info.st_size),
"size_formatted": format_file_size(info.st_size),
"modified": datetime.fromtimestamp(info.st_mtime).isoformat(),
"downloads": count
})
@@ -2249,8 +2249,10 @@ class APIv2(APIv1):
except Exception as e:
handler.send_json_response({"error": str(e)}, 500)
def api_start_sync(self, handler, source_name):
"""启动同步"""
def api_start_sync(self, handler, source_name=None):
"""启动同步(兼容 v1 调用:无 source_name 时回退到 v1 行为)"""
if source_name is None:
return super().api_start_sync(handler)
if hasattr(handler, 'sync_manager') and handler.sync_manager:
task_id = handler.sync_manager.start_sync(source_name)
if task_id:
@@ -2268,8 +2270,10 @@ class APIv2(APIv1):
else:
handler.send_json_response({"error": "Sync manager not available"}, 500)
def api_stop_sync(self, handler, source_name):
"""停止同步"""
def api_stop_sync(self, handler, source_name=None):
"""停止同步(兼容 v1 调用:无 source_name 时回退到 v1 行为)"""
if source_name is None:
return super().api_stop_sync(handler)
if hasattr(handler, 'sync_manager') and handler.sync_manager:
handler.sync_manager.stop_all_tasks_for_source(source_name)
handler.send_json_response({
@@ -2279,8 +2283,10 @@ class APIv2(APIv1):
else:
handler.send_json_response({"error": "Sync manager not available"}, 500)
def api_get_sync_status(self, handler, source_name):
"""获取同步状态(真实数据)"""
def api_get_sync_status(self, handler, source_name=None):
"""获取同步状态(真实数据;兼容 v1 调用)"""
if source_name is None:
return super().api_get_sync_status(handler)
# source_name 格式: source_name/status,需要提取
if source_name.endswith('/status'):
source_name = source_name[:-7]