You've already forked FrameTour-RenderWorker
chore(constant): 更新软件版本号至0.0.8
- 将 SOFTWARE_VERSION 从 0.0.6 更新到 0.0.8 feat(util/oss): 支持自定义rclone配置文件路径 - 新增读取环境变量 RCLONE_CONFIG_FILE 来指定配置文件 - 当 RCLONE_CONFIG_FILE 为空时默认使用 rclone.conf - 在调用 rclone 命令时加入 --config 参数以应用指定配置文件
This commit is contained in:
@@ -27,6 +27,10 @@ def upload_to_oss(url, file_path):
|
||||
if os.getenv("UPLOAD_METHOD") == "rclone":
|
||||
with tracer.start_as_current_span("rclone_to_oss") as r_span:
|
||||
replace_map = os.getenv("RCLONE_REPLACE_MAP")
|
||||
config_file = os.getenv("RCLONE_CONFIG_FILE")
|
||||
rclone_config = ""
|
||||
if config_file != "":
|
||||
rclone_config = f"--config {config_file}"
|
||||
r_span.set_attribute("rclone.replace_map", replace_map)
|
||||
if replace_map != "":
|
||||
replace_list = [i.split("|", 1) for i in replace_map.split(",")]
|
||||
@@ -36,7 +40,7 @@ def upload_to_oss(url, file_path):
|
||||
new_url = new_url.split("?", 1)[0]
|
||||
r_span.set_attribute("rclone.target_dir", new_url)
|
||||
if new_url != url:
|
||||
result = os.system(f"rclone copyto --no-check-dest --ignore-existing --multi-thread-chunk-size 8M --multi-thread-streams 8 {file_path} {new_url}")
|
||||
result = os.system(f"rclone copyto --no-check-dest --ignore-existing --multi-thread-chunk-size 8M --multi-thread-streams 8 {rclone_config} {file_path} {new_url}")
|
||||
r_span.set_attribute("rclone.result", result)
|
||||
if result == 0:
|
||||
span.set_status(Status(StatusCode.OK))
|
||||
|
||||
Reference in New Issue
Block a user