fix: [items source] filter invalid item sources

This commit is contained in:
Terrtia 2023-08-29 14:03:26 +02:00
parent 099253f854
commit 7c73f0944a
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -204,7 +204,11 @@ def _get_dir_source_name(directory, source_name=None, l_sources_name=set(), filt
if not l_sources_name: if not l_sources_name:
l_sources_name = set() l_sources_name = set()
if source_name: if source_name:
path = os.path.join(directory, source_name)
if os.path.isdir(path):
l_dir = os.listdir(os.path.join(directory, source_name)) l_dir = os.listdir(os.path.join(directory, source_name))
else:
l_dir = []
else: else:
l_dir = os.listdir(directory) l_dir = os.listdir(directory)
# empty directory # empty directory
@ -215,7 +219,7 @@ def _get_dir_source_name(directory, source_name=None, l_sources_name=set(), filt
return l_sources_name return l_sources_name
else: else:
for src_name in l_dir: for src_name in l_dir:
if len(src_name) == 4: if len(src_name) == 4 and source_name:
# try: # try:
int(src_name) int(src_name)
to_add = os.path.join(source_name) to_add = os.path.join(source_name)