]> git.treefish.org Git - photosort.git/blobdiff - src/registry.py
fixing registry query
[photosort.git] / src / registry.py
index 3d8cfd3fc393084c4c38b844bf112f7b33921c98..a2bad868dc71e3ca17a3facfc50036bcccc808bd 100644 (file)
@@ -15,27 +15,27 @@ class Registry:
             self._conn = sqlite3.connect(db_file, check_same_thread=False)
 
     def is_registered(self, name):
-        if not db_file: return False
+        if not self._conn: return False
         c = self._conn.cursor()
         c.execute("SELECT COUNT(*) FROM cache WHERE name=?", (name,))
-        return c.fetchone() != None
+        return c.fetchone()[0] == 1
 
     def clean(self):
-        if not db_file: return
+        if not self._conn: return
         c = self._conn.cursor()
         c.execute("DELETE FROM cache WHERE access_time<?", (int(time.time()) - 604800,))
         self._conn.commit()
 
 
     def register(self, name):
-        if not db_file: return
+        if not self._conn: return
         c = self._conn.cursor()
         c.execute( '''INSERT INTO cache (name, access_time) VALUES (?, ?)''',
                    (name, int(time.time())) )
         self._conn.commit()
 
     def refresh(self, name):
-        if not db_file: return
+        if not self._conn: return
         c = self._conn.cursor()
         c.execute( "UPDATE cache SET access_time=? WHERE name=?",
                    (int(time.time()), name) )