Skip to content

Commit

Permalink
fix(filemanager): 从未设置过目录同步的首次设置,报None Type no restrip
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyanling committed Sep 17, 2023
1 parent 299bfaa commit 662915c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions web/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,20 @@ def get_hardlink_info(folder):
result, sync_class, link_path, link_direction = match_sync_dir(folder, dir[1], dir[0], dir[2], '←')
if result: break
return sync_class, link_path, link_direction


def add_paths_to_media_dirs(paths, media_dirs):
"""
添加路径到媒体目录列表。
:param paths: 待添加的路径列表
:param media_dirs: 媒体目录列表
"""
if not paths:
return

valid_paths = [pathElement.rstrip('/') for pathElement in paths if StringUtils.is_string_and_not_empty(pathElement)]
media_dirs.extend(valid_paths)

def get_media_dirs():
"""
获取媒体库目录
Expand All @@ -1107,10 +1120,10 @@ def get_media_dirs():
tv_path = Config().get_config('media').get('tv_path')
anime_path = Config().get_config('media').get('anime_path')
unknown_path = Config().get_config('media').get('unknown_path')
if movie_path is not None: media_dirs.extend([path.rstrip('/') for path in movie_path])
if tv_path is not None: media_dirs.extend([path.rstrip('/') for path in tv_path])
if anime_path is not None: media_dirs.extend([path.rstrip('/') for path in anime_path])
if unknown_path is not None: media_dirs.extend([path.rstrip('/') for path in unknown_path])
add_paths_to_media_dirs(movie_path, media_dirs)
add_paths_to_media_dirs(tv_path, media_dirs)
add_paths_to_media_dirs(anime_path, media_dirs)
add_paths_to_media_dirs(unknown_path, media_dirs)
return list(set(media_dirs))

def get_download_dirs():
Expand Down

0 comments on commit 662915c

Please sign in to comment.