Change logic to check whether a user folder is empty or not

This commit is contained in:
Patrick Jentsch 2023-04-05 12:05:34 +02:00
parent 477e583be9
commit ca25ea0b80
2 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ def upgrade():
if os.path.exists(spacy_nlp_pipeline_models_dir):
if not os.path.isdir(spacy_nlp_pipeline_models_dir):
raise OSError(f'Not a directory: {spacy_nlp_pipeline_models_dir}')
if not os.listdir(spacy_nlp_pipeline_models_dir):
if len(os.listdir(spacy_nlp_pipeline_models_dir)) > 0:
raise OSError(f'Directory not empty: {spacy_nlp_pipeline_models_dir}')
else:
os.mkdir(spacy_nlp_pipeline_models_dir)

View File

@ -24,7 +24,7 @@ def upgrade():
if os.path.exists(users_dir):
if not os.path.isdir(users_dir):
raise OSError(f'Not a directory: {users_dir}')
if not os.listdir(users_dir):
if len(os.listdir(users_dir)) > 0:
raise OSError(f'Directory not empty: {users_dir}')
else:
os.mkdir(users_dir)