From 687166be2cd0993b6c03ef8d3b378729212fdbe5 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 19 Aug 2024 15:01:01 +0300 Subject: [PATCH] Feat(DB): Export/import column `show` --- dump_db.py | 4 ++-- reload_db.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dump_db.py b/dump_db.py index e2e6dc3..de790aa 100755 --- a/dump_db.py +++ b/dump_db.py @@ -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) ) diff --git a/reload_db.py b/reload_db.py index d2b3325..c6e9b19 100755 --- a/reload_db.py +++ b/reload_db.py @@ -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() -- 2.39.5