]> git.phdru.name Git - xsetbg.git/commitdiff
Feat(DB): Export/import column `show`
authorOleg Broytman <phd@phdru.name>
Mon, 19 Aug 2024 12:01:01 +0000 (15:01 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 19 Aug 2024 12:01:01 +0000 (15:01 +0300)
dump_db.py
reload_db.py

index e2e6dc3a5c0162ba6b010b3647fecda26eeeb309..de790aa6f04e19dfd1e5b4e978116a2ff0c77c09 100755 (executable)
@@ -16,7 +16,7 @@ fs_encoding = xsetbg_conf.get("images", "fs_encoding")
 for row in xsetbg_db.select(orderBy='-last_shown'):
     sys.stdout.buffer.write(
         (
-            '%d %s %d %s\n' %
-            (row.id, row.last_shown, row.is_image, row.full_name)
+            '%d %s %d %d %s\n' %
+            (row.id, row.last_shown, row.is_image, row.show, row.full_name)
         ).encode(fs_encoding)
     )
index d2b33256adc2f721ae3dd1045811d86cc59bd49e..c6e9b198ba8ce8e1a94a3be43119b4727f2256f2 100755 (executable)
@@ -26,10 +26,11 @@ count_new = count_old = count_updated = 0
 
 with SQLiteMassInsert() as txn:
     for line in dump_file:
-        id, timestamp, is_image, filename = line.strip().split(None, 3)
+        id, timestamp, is_image, show, filename = line.strip().split(None, 4)
         id = convert_str(id)
         timestamp = convert_str(timestamp)
         is_image = convert_str(is_image, bool)
+        show = convert_str(show, bool)
         try:
             if id:
                 row = xsetbg_db.get(id)
@@ -39,6 +40,7 @@ with SQLiteMassInsert() as txn:
             values = {'last_shown': timestamp,
                       'full_name': filename.encode('utf-8'),
                       'is_image': is_image,
+                      'show': show,
                      }
             if id:
                 values['id'] = id
@@ -56,6 +58,8 @@ with SQLiteMassInsert() as txn:
                 count_updated += 1
             if row.is_image != is_image:
                 row.is_image = is_image
+            if row.show != show:
+                row.show = show
 
 dump_file.close()