FIX make sure ads base directory exists

This commit is contained in:
Philipp K
2022-11-07 17:43:02 +01:00
committed by Sebastian Thomschke
parent faa71ac03f
commit 8bcd6f9ad8
2 changed files with 5 additions and 2 deletions

View File

@@ -815,8 +815,11 @@ class KleinanzeigenBot(SeleniumMixin):
Downloads an ad to a specific location, specified by config and ad_id.
"""
# create sub-directory for ad to download
# create sub-directory for ad to download:
relative_directory = str(self.config['ad_files'][0]).split('**', maxsplit=1)[0]
# make sure configured base directory exists
if not os.path.exists(relative_directory) or not os.path.isdir(relative_directory):
os.mkdir(relative_directory)
new_base_dir = os.path.join(relative_directory, f'ad_{self.ad_id}')
if os.path.exists(new_base_dir):
LOG.info('Deleting current folder of ad...')