Fix PDF generation for non-vanishing collection path

This commit is contained in:
iburadempa 2024-12-06 04:55:27 +01:00
parent 62bb338898
commit 1ee58510df

View file

@ -110,7 +110,7 @@ def get_settings():
settings_path = config_dir / 'settings.json' settings_path = config_dir / 'settings.json'
try: try:
with open(settings_path, 'r') as file: with open(settings_path, 'r') as file:
setting_cache = json.loads(file.read()) settings_cache = json.loads(file.read())
return deepcopy(settings_cache or {}) return deepcopy(settings_cache or {})
except Exception as err: except Exception as err:
logger.exception(err) logger.exception(err)
@ -216,7 +216,7 @@ def get_params(settings=None):
device_settings = settings.get('device_settings', {}).get(device_id, {}) device_settings = settings.get('device_settings', {}).get(device_id, {})
collection_choices = [str(d.relative_to(archive_dir)) collection_choices = [str(d.relative_to(archive_dir))
for d in archive_dir.glob('**') if d.is_dir()] for d in archive_dir.glob('**') if d.is_dir()]
collection_choices.sort(key=lambda x: x.lower()) collection_choices.sort(key=lambda x: x.lower())
return { return {
'devices': settings.get('devices', []), 'devices': settings.get('devices', []),
'device_id': device_id, 'device_id': device_id,
@ -569,7 +569,8 @@ async def create_pdf(pages, lossy: bool = False, ocr: bool = False):
for p in cache_dir_pdf.iterdir(): for p in cache_dir_pdf.iterdir():
p.unlink() p.unlink()
img_paths = [str(archive_dir / f'{page}.png') for page in pages] collection_choice = Path(get_settings().get('collection_choice', '.'))
img_paths = [str(archive_dir / collection_choice / f'{page}.png') for page in pages]
if lossy: if lossy:
cmd = [ cmd = [