fs_encoding = xsetbg_conf.get("images", "fs_encoding")
for row in xsetbg_db.select(orderBy='-last_shown'):
sys.stdout.buffer.write(
- ('%d %s %s\n' % (row.id, row.last_shown, row.full_name
- )).encode(fs_encoding)
+ (
+ '%d %s %d %s\n' %
+ (row.id, row.last_shown, row.is_image, row.full_name)
+ ).encode(fs_encoding)
)
from xsetbg_db import recreate_db, SQLiteMassInsert
-def convert_str(s):
+def convert_str(s, convert=int):
if s == "None":
return None
else:
- return int(float(s))
+ return convert(float(s))
dump_file = open(sys.argv[1], 'r',
with SQLiteMassInsert() as txn:
for line in dump_file:
- id, timestamp, filename = line.strip().split(None, 2)
+ id, timestamp, is_image, filename = line.strip().split(None, 3)
id = convert_str(id)
timestamp = convert_str(timestamp)
+ is_image = convert_str(is_image, bool)
try:
if id:
row = xsetbg_db.get(id)
row = xsetbg_db.byFull_name(filename)
except SQLObjectNotFound:
values = {'last_shown': timestamp,
- 'full_name': filename.encode('utf-8')}
+ 'full_name': filename.encode('utf-8'),
+ 'is_image': is_image,
+ }
if id:
values['id'] = id
query = txn.sqlrepr(Insert(xsetbg_db.sqlmeta.table, values=values))
else:
row.full_name = filename
count_updated += 1
+ if row.is_image != is_image:
+ row.is_image = is_image
dump_file.close()