Commit c1db9da1 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Handle dir deletion in windows

parent 36e99eca
......@@ -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]
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment