config.yaml 新增 path_mapping 段声明宿主机前缀与容器挂载点前缀的对应关系。 用户在 Web 界面和 config 里填宿主机真实路径(如群晖 /volume2/...), 程序在真正落盘、调用云盘 SDK 前透明转成容器内路径,保证文件写到 bind mount 而不是容器 overlay 文件系统;前端显示/返回的路径再反向转回宿主机形式。 无映射配置时所有 to_container/to_host 均原样返回,向后兼容老配置。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -15,6 +15,7 @@ from ruamel import yaml
|
||||
from module.cloud_drive import CloudDrive, CloudDriveConfig
|
||||
from module.filter import Filter
|
||||
from module.language import Language, set_language
|
||||
from module import path_mapper
|
||||
from utils.format import replace_date_time, validate_title
|
||||
from utils.meta_data import MetaData
|
||||
|
||||
@@ -433,6 +434,9 @@ class Application:
|
||||
"""
|
||||
# pylint: disable = R0912
|
||||
# TODO: judge the storage if enough,and provide more path
|
||||
# 先加载 path_mapping,后续 save_path / cloud_drive 路径都按此映射表解析
|
||||
path_mapper.load_mappings(_config.get("path_mapping", []))
|
||||
|
||||
if _config.get("save_path") is not None:
|
||||
self.save_path = _config["save_path"]
|
||||
|
||||
@@ -676,10 +680,12 @@ class Application:
|
||||
return False
|
||||
|
||||
ret: bool = False
|
||||
# 云盘上传也走容器路径,避免 SDK 在容器内找不到宿主机路径
|
||||
save_path_container = path_mapper.to_container(self.save_path)
|
||||
if self.cloud_drive_config.upload_adapter == "rclone":
|
||||
ret = await CloudDrive.rclone_upload_file(
|
||||
self.cloud_drive_config,
|
||||
self.save_path,
|
||||
save_path_container,
|
||||
local_file_path,
|
||||
progress_callback,
|
||||
progress_args,
|
||||
@@ -688,7 +694,7 @@ class Application:
|
||||
ret = await self.loop.run_in_executor(
|
||||
self.executor,
|
||||
CloudDrive.aligo_upload_file(
|
||||
self.cloud_drive_config, self.save_path, local_file_path
|
||||
self.cloud_drive_config, save_path_container, local_file_path
|
||||
),
|
||||
)
|
||||
|
||||
@@ -724,7 +730,8 @@ class Application:
|
||||
res = os.path.join(res, media_datetime)
|
||||
elif prefix == "media_type":
|
||||
res = os.path.join(res, media_type)
|
||||
return res
|
||||
# 真正落盘前把宿主机路径转成容器内挂载点路径,保证写到 bind mount 卷
|
||||
return path_mapper.to_container(res)
|
||||
|
||||
def get_file_name(
|
||||
self, message_id: int, file_name: Optional[str], caption: Optional[str]
|
||||
|
||||
Reference in New Issue
Block a user