Skip to content

Commit

Permalink
fix 文件整理
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Sep 21, 2024
1 parent d7e56ee commit c51826b
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions app/modules/filemanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,28 +447,18 @@ 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:
# 创建目录
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} 下载失败"
Expand Down

0 comments on commit c51826b

Please sign in to comment.