Преглед изворни кода

sqlite: default db_path to store.db; resolve relative paths from data_home()

ZiB пре 4 месеци
родитељ
комит
39a530fe6f
2 измењених фајлова са 5 додато и 4 уклоњено
  1. 2 2
      room_cal/_utils.py
  2. 3 2
      room_cal/store/_sqlite.py

+ 2 - 2
room_cal/_utils.py

@@ -350,11 +350,11 @@ class CaldavStoreConfig:
 
 @dataclass
 class SqliteStoreConfig:
-  db_path: str = ''
+  db_path: str = 'store.db'
 
   @classmethod
   def from_dict(cls, d: dict) -> 'SqliteStoreConfig':
-    return cls(db_path=d.get('db_path', ''))
+    return cls(db_path=d.get('db_path', 'store.db'))
 
 
 @dataclass

+ 3 - 2
room_cal/store/_sqlite.py

@@ -32,8 +32,9 @@ class SQLiteBackend:
   @classmethod
   def from_store_config(cls, store_cfg, calendar_name: str) -> 'SQLiteBackend':
     from room_cal._utils import data_home
-    db_path_str = store_cfg.sqlite.db_path
-    db_path = Path(db_path_str) if db_path_str else data_home() / 'store.db'
+    db_path = Path(store_cfg.sqlite.db_path)
+    if not db_path.is_absolute():
+      db_path = data_home() / db_path
     return cls(db_path, calendar_name)
 
   def _to_record(self, row) -> EventRecord: