fix 文件转移时无法覆盖

This commit is contained in:
jxxghp 2023-09-08 22:36:31 +08:00
parent 100ff97017
commit 3b73dfcdc6
2 changed files with 9 additions and 8 deletions

View File

@ -283,7 +283,7 @@ class FileTransferModule(_ModuleBase):
return retcode
def __transfer_file(self, file_item: Path, new_file: Path, transfer_type: str,
over_flag: bool = False, old_file: Path = None) -> int:
over_flag: bool = False) -> int:
"""
转移一个文件同时处理其他相关文件
:param file_item: 原文件路径
@ -291,12 +291,13 @@ class FileTransferModule(_ModuleBase):
:param transfer_type: RmtMode转移方式
:param over_flag: 是否覆盖为True时会先删除再转移
"""
if not over_flag and new_file.exists():
logger.warn(f"文件已存在:{new_file}")
return 0
if over_flag and old_file and old_file.exists():
logger.info(f"正在删除已存在的文件:{old_file}")
old_file.unlink()
if new_file.exists():
if not over_flag:
logger.warn(f"文件已存在:{new_file}")
return 0
else:
logger.info(f"正在删除已存在的文件:{new_file}")
new_file.unlink()
logger.info(f"正在转移文件:{file_item}{new_file}")
# 创建父目录
new_file.parent.mkdir(parents=True, exist_ok=True)

View File

@ -798,7 +798,7 @@ class BrushFlow(_PluginBase):
},
{
'component': 'td',
'text': data.get('ratio')
'text': round(data.get('ratio') or 0, 2)
},
{
'component': 'td',