Commit 09b625a9 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

use os.listdir() to determine actual path

parent 12b1979f
...@@ -139,8 +139,8 @@ def info_is_unhandled(info): ...@@ -139,8 +139,8 @@ def info_is_unhandled(info):
return info != {} and info[LOCALFS_TYPE] == common.T_UNHANDLED return info != {} and info[LOCALFS_TYPE] == common.T_UNHANDLED
def local_path_changes(path, state, unhandled_equal=True): def local_path_changes(settings, path, state, unhandled_equal=True):
live_info = get_live_info(path) live_info = get_live_info(settings, path)
info = state.info info = state.info
if is_info_eq(live_info, info, unhandled_equal): if is_info_eq(live_info, info, unhandled_equal):
return None return None
...@@ -160,15 +160,20 @@ def get_actual_windows_path(path): ...@@ -160,15 +160,20 @@ def get_actual_windows_path(path):
return buf.value return buf.value
def get_live_info(path): def is_actual_path(path):
prefix = path.rstrip(os.path.sep)
while True:
prefix, basename = os.path.split(prefix)
if not basename:
return True
if not basename in os.listdir(prefix):
return False
def get_live_info(settings, path):
if path is None: if path is None:
return {} return {}
if utils.iswin(): if settings.case_insensitive:
try: if not is_actual_path(path):
actual_path = get_actual_windows_path(path)
if path != actual_path:
return {}
except ValueError:
return {} return {}
stats, status = get_local_status(path) stats, status = get_local_status(path)
if status == LOCAL_MISSING: if status == LOCAL_MISSING:
...@@ -359,7 +364,7 @@ class LocalfsTargetHandle(object): ...@@ -359,7 +364,7 @@ class LocalfsTargetHandle(object):
def prepare(self, fetched_path, sync_state): def prepare(self, fetched_path, sync_state):
self.hide_file() self.hide_file()
info_changed = local_path_changes( info_changed = local_path_changes(self.settings,
self.hidden_path, sync_state, unhandled_equal=False) self.hidden_path, sync_state, unhandled_equal=False)
if info_changed is not None and info_changed != {}: if info_changed is not None and info_changed != {}:
if not files_equal(self.hidden_path, fetched_path): if not files_equal(self.hidden_path, fetched_path):
...@@ -405,7 +410,7 @@ class LocalfsTargetHandle(object): ...@@ -405,7 +410,7 @@ class LocalfsTargetHandle(object):
def pull(self, source_handle, sync_state): def pull(self, source_handle, sync_state):
fetched_path = source_handle.send_file(sync_state) fetched_path = source_handle.send_file(sync_state)
fetched_live_info = get_live_info(fetched_path) fetched_live_info = get_live_info(self.settings, fetched_path)
self.apply(fetched_path, fetched_live_info, sync_state) self.apply(fetched_path, fetched_live_info, sync_state)
self.cleanup(fetched_path) self.cleanup(fetched_path)
return self.target_state.set(info=fetched_live_info) return self.target_state.set(info=fetched_live_info)
...@@ -465,7 +470,7 @@ class LocalfsSourceHandle(object): ...@@ -465,7 +470,7 @@ class LocalfsSourceHandle(object):
def stage_file(self): def stage_file(self):
self.copy_file() self.copy_file()
live_info = get_live_info(self.fspath) live_info = get_live_info(self.settings, self.fspath)
self.check_staged(live_info) self.check_staged(live_info)
self.check_update_source_state(live_info) self.check_update_source_state(live_info)
...@@ -645,7 +650,7 @@ class LocalfsFileClient(FileClient): ...@@ -645,7 +650,7 @@ class LocalfsFileClient(FileClient):
def _local_path_changes(self, name, state): def _local_path_changes(self, name, state):
local_path = utils.join_path(self.ROOTPATH, name) local_path = utils.join_path(self.ROOTPATH, name)
return local_path_changes(local_path, state) return local_path_changes(self.settings, local_path, state)
def exclude_file(self, objname): def exclude_file(self, objname):
parts = objname.split(common.OBJECT_DIRSEP) parts = objname.split(common.OBJECT_DIRSEP)
......
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