fix 同路径优先

This commit is contained in:
jxxghp 2024-05-27 07:52:36 +08:00
parent dd5887d18d
commit ca5a240fc4

View File

@ -112,14 +112,6 @@ class DirectoryHelper:
# 有源路径,且开启同盘/同目录优先时 # 有源路径,且开启同盘/同目录优先时
if in_path and settings.TRANSFER_SAME_DISK: 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 max_length = 0
target_dir = None target_dir = None
@ -139,5 +131,14 @@ class DirectoryHelper:
continue continue
if target_dir: if target_dir:
return 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] return matched_dirs[0]