diff options
-rw-r--r-- | client.py | 2 | ||||
-rw-r--r-- | server.py | 16 |
2 files changed, 9 insertions, 9 deletions
@@ -2,4 +2,4 @@ import sys import xmlrpc.client proxy = xmlrpc.client.ServerProxy("http://localhost:8000") -print('\n'.join(proxy.search(sys.argv[1], sys.argv[2]))) +print("\n".join(proxy.search(sys.argv[1], sys.argv[2]))) @@ -49,6 +49,7 @@ class EventHandler(FileSystemEventHandler): "INSERT OR REPLACE INTO idx VALUES (?, ?, ?, ?)", (s.st_ino, get_parent(event.dest_path), s.st_mtime, event.dest_path), ) + cur.execute("UPDATE idx SET path = replace(path, ?, ?)", (event.src_path, event.dest_path)) con.commit() @@ -83,7 +84,12 @@ def index(path, parent): return cur.execute("INSERT OR REPLACE INTO emb VALUES (?, ?)", (s.st_ino, emb.numpy())) - else: + cur.execute( + "INSERT OR REPLACE INTO idx VALUES (?, ?, ?, ?)", + (s.st_ino, parent, s.st_mtime, path), + ) + con.commit() + if os.path.isdir(path): if parent: children = os.listdir(path) else: @@ -105,12 +111,6 @@ def index(path, parent): observer.schedule(event_handler, child, recursive=True) index(os.path.join(path, child), s.st_ino) - cur.execute( - "INSERT OR REPLACE INTO idx VALUES (?, ?, ?, ?)", - (s.st_ino, parent, s.st_mtime, path), - ) - con.commit() - def unindex(id): print("Unindexing", id) @@ -133,7 +133,7 @@ def search(text, limit): print("Indexing files") -watchdirs = set(sys.argv[1:]) +watchdirs = set(map(os.path.abspath, sys.argv[1:])) observer = Observer() event_handler = EventHandler() # Pretend that / is the parent of all indexed dirs |