]> git.treefish.org Git - photosort.git/blobdiff - src/registry.py
fixing null registry checks
[photosort.git] / src / registry.py
index 3d8cfd3fc393084c4c38b844bf112f7b33921c98..4eff031387c37afcb0b3778b9b421c371236ba36 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
 
     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) )