From 50a85618d53212bc00e70b015d67f8d35fea893c Mon Sep 17 00:00:00 2001 From: Herman Snevajs Date: Wed, 22 Jul 2026 14:23:28 +0200 Subject: [PATCH] Fix phantom GeoPackage created from default references config --- config.yaml.default | 13 ++++++++----- media_sync.py | 9 ++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config.yaml.default b/config.yaml.default index d72d66f..cd9dc89 100644 --- a/config.yaml.default +++ b/config.yaml.default @@ -29,11 +29,14 @@ google_drive: folder: share_with: -references: - - file: survey.gpkg - table: notes - local_path_column: photo - driver_path_column: ext_url +# Reference rewriting is optional and OFF by default. Uncomment and adjust to +# have media-sync write uploaded file URLs into a GeoPackage table. Leave empty to only copy files. +references: [] +#references: +# - file: survey.gpkg +# table: notes +# local_path_column: photo +# driver_path_column: ext_url daemon: sleep_time: 10 diff --git a/media_sync.py b/media_sync.py index f3a6ec8..043be0c 100644 --- a/media_sync.py +++ b/media_sync.py @@ -159,11 +159,14 @@ def _update_references(files): if not all(reference_config): return + gpkg_path = os.path.join(config.project_working_dir, ref.file) + if not os.path.exists(gpkg_path): + print(f"Skipping references - file not found in project: {ref.file}") + continue + print("Updating references ...") try: - gpkg_conn = sqlite3.connect( - os.path.join(config.project_working_dir, ref.file) - ) + gpkg_conn = sqlite3.connect(gpkg_path) gpkg_conn.enable_load_extension(True) gpkg_cur = gpkg_conn.cursor() gpkg_cur.execute('SELECT load_extension("mod_spatialite")')