fix 目录健康检查
This commit is contained in:
parent
58acc62e16
commit
5c8b843030
@ -48,23 +48,27 @@ class DirectoryHelper:
|
|||||||
media_type = media.type.value
|
media_type = media.type.value
|
||||||
else:
|
else:
|
||||||
media_type = MediaType.UNKNOWN.value
|
media_type = MediaType.UNKNOWN.value
|
||||||
media_dirs = self.get_download_dirs()
|
download_dirs = self.get_download_dirs()
|
||||||
# 按照配置顺序查找(保存后的数据已经排序)
|
# 按照配置顺序查找(保存后的数据已经排序)
|
||||||
for media_dir in media_dirs:
|
for download_dir in download_dirs:
|
||||||
if not media_dir.path:
|
if not download_dir.path:
|
||||||
continue
|
continue
|
||||||
|
download_path = Path(download_dir.path)
|
||||||
# 有目标目录,但目标目录与当前目录不相等时不要
|
# 有目标目录,但目标目录与当前目录不相等时不要
|
||||||
if to_path and Path(media_dir.path) != to_path:
|
if to_path and download_path != to_path:
|
||||||
continue
|
continue
|
||||||
|
# 不存在目录则创建
|
||||||
|
if not download_path.exists():
|
||||||
|
download_path.mkdir(parents=True, exist_ok=True)
|
||||||
# 目录类型为全部的,符合条件
|
# 目录类型为全部的,符合条件
|
||||||
if not media_dir.media_type:
|
if not download_dir.media_type:
|
||||||
return media_dir
|
return download_dir
|
||||||
# 目录类型相等,目录类别为全部,符合条件
|
# 目录类型相等,目录类别为全部,符合条件
|
||||||
if media_dir.media_type == media_type and not media_dir.category:
|
if download_dir.media_type == media_type and not download_dir.category:
|
||||||
return media_dir
|
return download_dir
|
||||||
# 目录类型相等,目录类别相等,符合条件
|
# 目录类型相等,目录类别相等,符合条件
|
||||||
if media_dir.media_type == media_type and media_dir.category == media.category:
|
if download_dir.media_type == media_type and download_dir.category == media.category:
|
||||||
return media_dir
|
return download_dir
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -106,6 +110,12 @@ class DirectoryHelper:
|
|||||||
if not matched_dirs:
|
if not matched_dirs:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# 没有目录则创建
|
||||||
|
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 len(matched_dirs) == 1:
|
if len(matched_dirs) == 1:
|
||||||
return matched_dirs[0]
|
return matched_dirs[0]
|
||||||
@ -135,8 +145,6 @@ class DirectoryHelper:
|
|||||||
# 优先同盘
|
# 优先同盘
|
||||||
for matched_dir in matched_dirs:
|
for matched_dir in matched_dirs:
|
||||||
matched_path = Path(matched_dir.path)
|
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):
|
if SystemUtils.is_same_disk(matched_path, in_path):
|
||||||
return matched_dir
|
return matched_dir
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user