新增重存模式处理子目录更新 #67
Some checks are pending
Docker Publish / build-and-push (push) Waiting to run

- 重存模式下,删除整个子目录并重新转存
- 新增提示信息,帮助用户选择合适的处理模式
This commit is contained in:
Cp0204 2025-06-26 01:00:23 +08:00
parent 59e024fd40
commit 8e27444f0e
2 changed files with 39 additions and 5 deletions

View File

@ -358,10 +358,17 @@
</div>
</div>
</div>
<div class="form-group row" title="需匹配到各级嵌套目录名才会更新,否则子目录在第一次转存后不会更新。注意:原理是逐级索引,深层嵌套目录的场景下效率非常低,慎用 .*">
<div class="form-group row" title="需匹配到各级嵌套目录名才会更新,否则子目录在第一次转存后不会更新。注意:递归模式原理是逐级索引,深层嵌套目录的场景下效率非常低,慎用 .*">
<label class="col-sm-2 col-form-label">更新目录</label>
<div class="col-sm-10">
<input type="text" name="update_subdir[]" class="form-control" v-model="task.update_subdir" placeholder="可选,匹配需更新子目录(含各级嵌套目录)的正则表达式,多项以|分割,如 4k|1080p">
<div class="input-group">
<input type="text" name="update_subdir[]" class="form-control" v-model="task.update_subdir" placeholder="可选,匹配需更新子目录(含各级嵌套目录)的正则表达式,多项以|分割,如 4k|1080p">
<div class="input-group-append" title="重存模式:删除该目录下所有文件,重新转存,大资源包时推荐使用&#x0A;不勾选为递归模式:递归检查,逐级更新嵌套目录,效率低">
<div class="input-group-text">
<input type="checkbox" v-model="task.update_subdir_resave_mode">&nbsp;重存模式
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">

View File

@ -613,7 +613,7 @@ class Quark:
"__t": datetime.now().timestamp(),
}
response = self._send_request("GET", url, params=querystring).json()
if response["data"]["status"] != 0:
if response["data"]["status"] == 2:
if retry_index > 0:
print()
break
@ -902,8 +902,35 @@ class Quark:
need_save_list.append(share_file)
elif share_file["dir"]:
# 存在并是一个目录,历遍子目录
if task.get("update_subdir", False):
if re.search(task["update_subdir"], share_file["file_name"]):
if task.get("update_subdir", False) and re.search(
task["update_subdir"], share_file["file_name"]
):
if task.get("update_subdir_resave_mode", False):
# 重存模式:删除该目录下所有文件,重新转存
print(f"重存子目录:{savepath}/{share_file['file_name']}")
# 删除子目录、回收站中彻底删除
subdir = next(
(
f
for f in dir_file_list
if f["file_name"] == share_file["file_name"]
),
None,
)
delete_return = self.delete([subdir["fid"]])
self.query_task(delete_return["data"]["task_id"])
recycle_list = self.recycle_list()
record_id_list = [
item["record_id"]
for item in recycle_list
if item["fid"] == subdir["fid"]
]
self.recycle_remove(record_id_list)
# 作为新文件添加到转存列表
share_file["file_name_re"] = share_file["file_name"]
need_save_list.append(share_file)
else:
# 递归模式
print(f"检查子目录:{savepath}/{share_file['file_name']}")
subdir_tree = self.dir_check_and_save(
task,