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

Fix sep issues

parent e5931f22
from collections import namedtuple
import threading
OBJECT_DIRSEP = '/'
FileStateTuple = namedtuple('FileStateTuple',
['archive', 'objname', 'serial', 'info'])
......
......@@ -467,12 +467,16 @@ class LocalfsFileClient(FileClient):
# if self.exclude_dir_exp.match(dirpath):
# continue
if rel_dirpath != '.':
candidates[rel_dirpath] = None
candidates[utils.to_standard_sep(rel_dirpath)] = None
for filename in files:
# if self.exclude_files_exp.match(filename) or \
# self.exclude_dir_exp.match(filename):
# continue
objname = utils.join_path(rel_dirpath, filename)
if rel_dirpath == '.':
prefix = ""
else:
prefix = utils.to_standard_sep(rel_dirpath)
objname = utils.join_objname(prefix, filename)
candidates[objname] = None
db_cands = dict((name, None) for name in db.list_files(self.SIGNATURE))
......@@ -507,8 +511,9 @@ class LocalfsFileClient(FileClient):
def notifier(self, callback=None):
def handle_path(path):
rel_path = os.path.relpath(path, start=self.ROOTPATH)
objname = utils.to_standard_sep(rel_path)
if callback is not None:
callback(self.SIGNATURE, rel_path)
callback(self.SIGNATURE, objname)
class EventHandler(FileSystemEventHandler):
def on_created(this, event):
......
......@@ -2,7 +2,6 @@ import time
import threading
import logging
import re
import os
from agkyra.syncer import common
from agkyra.syncer.setup import SyncerSettings
......@@ -69,7 +68,7 @@ class FileSyncer(object):
self.decide_event.clear()
def exclude_file(self, objname):
parts = objname.split(os.path.sep)
parts = objname.split(common.OBJECT_DIRSEP)
init_part = parts[0]
if init_part in [self.settings.cache_name]:
return True
......
......@@ -2,13 +2,27 @@ import os
import hashlib
import datetime
from agkyra.syncer.common import OBJECT_DIRSEP
BUF_SIZE = 65536
def to_local_sep(filename):
return filename.replace(OBJECT_DIRSEP, os.path.sep)
def to_standard_sep(filename):
return filename.replace(os.path.sep, OBJECT_DIRSEP)
def join_path(dirpath, filename):
if dirpath == ".":
dirpath = ""
return os.path.join(dirpath, filename)
return os.path.join(dirpath, to_local_sep(filename))
def join_objname(prefix, filename):
if prefix != "":
prefix = prefix.rstrip(OBJECT_DIRSEP) + OBJECT_DIRSEP
return prefix + filename
def hash_string(s):
......
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