diff --git a/agkyra/syncer/database.py b/agkyra/syncer/database.py index d932826945bec8ae948297ec45fd7d141bfcba4c..04ff901ed1d69355c0728f799f63d53d76b0d36b 100644 --- a/agkyra/syncer/database.py +++ b/agkyra/syncer/database.py @@ -20,7 +20,7 @@ import json import logging import random -from agkyra.syncer import common +from agkyra.syncer import common, utils logger = logging.getLogger(__name__) @@ -155,6 +155,17 @@ class SqliteFileStateDB(FileStateDB): break yield r[0] + def get_dir_contents(self, archive, objname): + Q = ("select objname from archives where archive = ? and info != '{}'" + " and objname like ?") + c = self.db.execute(Q, (archive, utils.join_objname(objname, '%'))) + fetchone = c.fetchone + while True: + r = fetchone() + if not r: + break + yield r[0] + def list_deciding(self, archives, sync): if len(archives) == 1: archive = archives[0] diff --git a/agkyra/syncer/localfs_client.py b/agkyra/syncer/localfs_client.py index a56d81e54b2c46f014574664bea7826e347ec061..2d997e5ace0d4ac81db1a1a261fd7361db37bf91 100644 --- a/agkyra/syncer/localfs_client.py +++ b/agkyra/syncer/localfs_client.py @@ -683,8 +683,13 @@ class LocalfsFileClient(FileClient): def prepare_target(self, target_state): return LocalfsTargetHandle(self.settings, target_state) + @transaction() + def get_dir_contents(self, objname): + db = self.get_db() + return db.get_dir_contents(self.SIGNATURE, objname) + def notifier(self): - def handle_path(path): + def handle_path(path, rec=False): try: path = utils.to_unicode(path) except UnicodeDecodeError as e: @@ -695,6 +700,10 @@ class LocalfsFileClient(FileClient): objname = utils.to_standard_sep(rel_path) with self.probe_candidates.lock() as d: d[objname] = self.none_info() + if rec: + leaves = self.get_dir_contents(objname) + for leaf in leaves: + d[leaf] = self.none_info() root_path = utils.from_unicode(self.ROOTPATH) class EventHandler(FileSystemEventHandler): @@ -712,7 +721,7 @@ class LocalfsFileClient(FileClient): self.settings.set_localfs_enabled(False) msg = messaging.LocalfsSyncDisabled(logger=logger) self.settings.messager.put(msg) - handle_path(path) + handle_path(path, rec=utils.iswin()) def on_modified(this, event): if event.is_directory: