From b971b05a2dd31e94053eb850d968a7ec41fee2e5 Mon Sep 17 00:00:00 2001 From: lededev Date: Wed, 31 Mar 2021 07:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E8=B5=B0=E6=96=87=E4=BB=B6=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=9C=A8=E5=8E=9F=E6=9D=A5=E4=BD=8D=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=8F=AF=E8=BF=BD=E6=BA=AF=E7=9A=84?= =?UTF-8?q?=E8=BD=AF=E9=93=BE=E6=8E=A5=EF=BC=8C=E6=8C=87=E5=90=91=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=96=B0=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core.py b/core.py index e7e3975..5669bfa 100755 --- a/core.py +++ b/core.py @@ -585,13 +585,20 @@ def paste_file_to_folder(filepath, path, number, c_word, conf: config.Config): houzhui = os.path.splitext(filepath)[1].replace(",","") file_parent_origin_path = str(pathlib.Path(filepath).parent) try: + targetpath = path + '/' + number + c_word + houzhui # 如果soft_link=1 使用软链接 if conf.soft_link(): - os.symlink(filepath, path + '/' + number + c_word + houzhui) + os.symlink(filepath, targetpath) else: - os.rename(filepath, path + '/' + number + c_word + houzhui) + os.rename(filepath, targetpath) + # 移走文件后,在原来位置增加一个可追溯的软链接,指向文件新位置 + # 以便追查文件从原先位置被移动到哪里了,避免因为得到错误番号后改名移动导致的文件失踪 + # 便于手工找回文件。并将软连接文件名后缀修改,以避免再次被搜刮。 + targetabspath = os.path.abspath(targetpath) + if targetabspath != os.path.abspath(filepath): + os.symlink(targetabspath, filepath + '#sym') sub_res = conf.sub_rule() - + for subname in sub_res: if os.path.exists(number + c_word + subname): # 字幕移动 os.rename(number + c_word + subname, path + '/' + number + c_word + subname)