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

View File

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