]> git.phdru.name Git - xsetbg.git/blobdiff - rescan_fs.py
Build: For Python 3.13 SQLObject requires unreleased FormEncode
[xsetbg.git] / rescan_fs.py
index 346f92b28f387c3434731ec9d0e19e4949955aa2..b8284a93b55c8b263c0f5631adafff80cebf3523 100755 (executable)
@@ -52,7 +52,7 @@ NULL = open(os.devnull, 'w')
 
 def is_image(full_path):
     # Run `identify` from ImageMagic; convert retcode to bool
-    return not subprocess.call(['identify', full_path],
+    return not subprocess.call(['identify', full_path.encode(fs_encoding)],
                                stdout=NULL, stderr=subprocess.STDOUT)
 
 
@@ -67,9 +67,11 @@ with SQLiteMassInsert() as txn:
                 try:
                     row = xsetbg_db.byFull_name(full_name)
                 except SQLObjectNotFound:
-                    values = {'full_name': full_name.encode('utf-8'),
-                              'is_image': is_image(full_name),
+                    image_and_show = is_image(full_name)
+                    values = {'full_name': full_name,
+                              'is_image': image_and_show,
                               'flag': True,
+                              'show': image_and_show,
                               }
                     query = txn.sqlrepr(Insert(xsetbg_db.sqlmeta.table,
                                                values=values))
@@ -77,7 +79,8 @@ with SQLiteMassInsert() as txn:
                     count_new += 1
                 else:
                     if row.is_image is None:
-                        row.is_image = is_image(full_name)
+                        row.is_image = image_and_show = is_image(full_name)
+                        row.show = image_and_show
                     row.flag = True
                     count_old += 1
     count_del = xsetbg_db.select('flag IS NULL').count()