From 9a810f440d51cc20b48489d4f4e43a10efa3669f Mon Sep 17 00:00:00 2001 From: Shurelol Date: Thu, 26 Oct 2023 15:24:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=BD=AC=E7=A7=BB?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E6=A8=A1=E5=BC=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ app/core/config.py | 2 ++ app/modules/filetransfer/__init__.py | 17 ++++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f3fcf51..368931a0 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,8 @@ MoviePilot需要配套下载器和媒体服务器配合使用。 - **BIG_MEMORY_MODE:** 大内存模式,默认为`false`,开启后会占用更多的内存,但响应速度会更快 +- **OVERWRITE_MODE:** 转移覆盖模式,默认为`nerver`,支持`nerver`/`size`/`always`,分别表示`不覆盖`/`根据大小覆盖(大覆盖小)`/`总是覆盖` + - **MOVIE_RENAME_FORMAT:** 电影重命名格式 `MOVIE_RENAME_FORMAT`支持的配置项: diff --git a/app/core/config.py b/app/core/config.py index 4f657ffc..f5f2cbf5 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -204,6 +204,8 @@ class Settings(BaseSettings): "/Season {{season}}" \ "/{{title}} - {{season_episode}}{% if part %}-{{part}}{% endif %}{% if episode %} - 第 {{episode}} 集{% endif %}" \ "{{fileExt}}" + # 转移时覆盖模式 + OVERWRITE_MODE: str = "nerver" # 大内存模式 BIG_MEMORY_MODE: bool = False diff --git a/app/modules/filetransfer/__init__.py b/app/modules/filetransfer/__init__.py index c94bac0b..6244b752 100644 --- a/app/modules/filetransfer/__init__.py +++ b/app/modules/filetransfer/__init__.py @@ -468,9 +468,20 @@ class FileTransferModule(_ModuleBase): # 判断是否要覆盖 overflag = False if new_file.exists(): - if new_file.stat().st_size < in_path.stat().st_size: - logger.info(f"目标文件已存在,但文件大小更小,将覆盖:{new_file}") - overflag = True + # 目标文件已存在 + match settings.OVERWRITE_MODE: + case 'always': + overflag = True + logger.info(f"目标文件已存在,将被覆盖:{new_file}") + case 'size': + if new_file.stat().st_size < in_path.stat().st_size: + logger.info(f"目标文件已存在,但文件大小更小,将被覆盖:{new_file}") + overflag = True + case 'never': + overflag = False + logger.info(f"目标文件已存在,停止转移") + case _: + pass # 原文件大小 file_size = in_path.stat().st_size # 转移文件