From ca5a240fc4bd883a53427fc2d61c89d43d3437c1 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 27 May 2024 07:52:36 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=90=8C=E8=B7=AF=E5=BE=84=E4=BC=98?= =?UTF-8?q?=E5=85=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helper/directory.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/helper/directory.py b/app/helper/directory.py index 2e44cbf2..12ff9577 100644 --- a/app/helper/directory.py +++ b/app/helper/directory.py @@ -112,14 +112,6 @@ class DirectoryHelper: # 有源路径,且开启同盘/同目录优先时 if in_path and settings.TRANSFER_SAME_DISK: - # 优先同盘 - for matched_dir in matched_dirs: - matched_path = Path(matched_dir.path) - if not matched_path.exists(): - matched_path.mkdir(parents=True, exist_ok=True) - if SystemUtils.is_same_disk(matched_path, in_path): - return matched_dir - # 优先同根路径 max_length = 0 target_dir = None @@ -139,5 +131,14 @@ class DirectoryHelper: continue if target_dir: return target_dir + + # 优先同盘 + for matched_dir in matched_dirs: + matched_path = Path(matched_dir.path) + if not matched_path.exists(): + matched_path.mkdir(parents=True, exist_ok=True) + if SystemUtils.is_same_disk(matched_path, in_path): + return matched_dir + # 返回最优先的匹配 return matched_dirs[0]