From c51826ba4c60c7eb6f0f521d34635b12eb3bdbd6 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 21 Sep 2024 17:11:12 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=96=87=E4=BB=B6=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/filemanager/__init__.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/app/modules/filemanager/__init__.py b/app/modules/filemanager/__init__.py index dbb769845..fa0c76694 100644 --- a/app/modules/filemanager/__init__.py +++ b/app/modules/filemanager/__init__.py @@ -447,7 +447,7 @@ def __get_targetitem(_path: Path) -> FileItem: logger.warn(f"文件已存在:{target_file}") return __get_targetitem(target_file), "" # 网盘到本地 - if transfer_type == "copy": + if transfer_type in ["copy", "move"]: # 下载 tmp_file = source_oper.download(fileitem) if tmp_file: @@ -455,20 +455,10 @@ def __get_targetitem(_path: Path) -> FileItem: if not target_file.parent.exists(): target_file.parent.mkdir(parents=True) # 将tmp_file移动后target_file - tmp_file.rename(target_file) - return __get_targetitem(target_file), "" - else: - return None, f"{fileitem.path} {fileitem.storage} 下载失败" - elif transfer_type == "move": - # 下载 - tmp_file = source_oper.download(fileitem) - if tmp_file: - if not target_file.parent.exists(): - target_file.parent.mkdir(parents=True) - # 将tmp_file移动后target_file - tmp_file.rename(target_file) - # 删除源文件 - source_oper.delete(fileitem) + SystemUtils.move(tmp_file, target_file) + if transfer_type == "move": + # 删除源文件 + source_oper.delete(fileitem) return __get_targetitem(target_file), "" else: return None, f"{fileitem.path} {fileitem.storage} 下载失败"