diff --git a/BookfusionBackSync.zip b/BookfusionBackSync.zip index 4fd5fae..b972635 100644 Binary files a/BookfusionBackSync.zip and b/BookfusionBackSync.zip differ diff --git a/BookfusionBackSync/main.py b/BookfusionBackSync/main.py index 762b593..b29def9 100644 --- a/BookfusionBackSync/main.py +++ b/BookfusionBackSync/main.py @@ -68,7 +68,10 @@ class MainDialog(QDialog): self.status_label.setText('Starting…') self.progress_bar.setValue(0) - self.worker = SyncWorker(self.gui.current_db.new_api) + self.worker = SyncWorker( + self.gui.current_db.new_api, + self.gui.current_db.library_path, + ) self.worker.log_message.connect(self._on_log) self.worker.progress.connect(self._on_progress) self.worker.status.connect(self.status_label.setText) diff --git a/BookfusionBackSync/sync_worker.py b/BookfusionBackSync/sync_worker.py index 28b522a..cc3a4d7 100644 --- a/BookfusionBackSync/sync_worker.py +++ b/BookfusionBackSync/sync_worker.py @@ -3,6 +3,7 @@ __license__ = 'GPL v3' import json import logging import os +import tempfile import time import uuid import urllib.request @@ -33,9 +34,10 @@ class SyncWorker(QThread): status = pyqtSignal(str) finished = pyqtSignal(int, int) # updated, skipped - def __init__(self, db): + def __init__(self, db, library_path=None): QThread.__init__(self) self.db = db + self.library_path = library_path self._stop = False self._log = logging.getLogger('bookfusionbacksync') @@ -54,7 +56,10 @@ class SyncWorker(QThread): # ── File logging ───────────────────────────────────────────────────────── def _setup_logging(self): - log_path = os.path.join(self.db.library_path, 'bookfusionbacksync.log') + base_path = self.library_path or getattr(self.db, 'library_path', None) + if not base_path: + base_path = tempfile.gettempdir() + log_path = os.path.join(base_path, 'bookfusionbacksync.log') logger = logging.getLogger('bookfusionbacksync') logger.setLevel(logging.DEBUG) logger.handlers.clear() @@ -228,7 +233,6 @@ class SyncWorker(QThread): 'token': token, 'page': page, 'per_page': 100, - 'sort': 'last_read_at-desc', }) page_data = self._fetch_json(f'{_API_BASE}/v3/library/books.json?{params}') if not page_data: