diff options
author | Joerg Steffens <joerg.steffens@dass-it.de> | 2015-09-16 23:22:17 +0300 |
---|---|---|
committer | Joerg Steffens <joerg.steffens@dass-it.de> | 2015-09-16 23:22:17 +0300 |
commit | 4d37fa6511ee069d4ab03fdd80e34391351321f1 (patch) | |
tree | b316fd218dbb99ba379989ec300b1c87901b2ad7 | |
parent | 5f6838d98fcb42d68c51ca553f73086c9f0a1b12 (diff) |
replaced path lstrip() by shift()
-rw-r--r-- | bareos/fuse/node/base.py | 8 | ||||
-rw-r--r-- | bareos/fuse/node/directory.py | 3 | ||||
-rw-r--r-- | bareos/util/path.py | 27 |
3 files changed, 25 insertions, 13 deletions
diff --git a/bareos/fuse/node/base.py b/bareos/fuse/node/base.py index 15e844a..c0cdd12 100644 --- a/bareos/fuse/node/base.py +++ b/bareos/fuse/node/base.py @@ -39,7 +39,8 @@ class Base(object): result = self.get_stat() else: if path.get(0) in self.subnodes: - result = self.subnodes[path.get(0)].getattr(path.lstrip([path.get(0)])) + topdir = path.shift() + result = self.subnodes[topdir].getattr(path) return result def get_stat(self): @@ -60,11 +61,13 @@ class Base(object): uid = pwd.getpwnam(stat['user']).pw_uid self.stat.st_uid = uid except KeyError as e: + self.logger.info("user %s not known on this system, fall back to uid 0" % (stat['user'])) pass try: gid = grp.getgrnam(stat['group']).gr_gid self.stat.st_gid = gid except KeyError as e: + self.logger.info("group %s not known on this system, fall back to gid 0" % (stat['group'])) pass #"stat": { #"atime": 1441134679, @@ -90,7 +93,8 @@ class Base(object): result = self.content[offset:offset+size] else: if path.get(0) in self.subnodes: - result = self.subnodes[path.get(0)].read(path.lstrip([path.get(0)]), size, offset) + topdir = path.shift() + result = self.subnodes[topdir].read(path, size, offset) return result def add_subnode(self, obj): diff --git a/bareos/fuse/node/directory.py b/bareos/fuse/node/directory.py index 90fb3da..3e5feb2 100644 --- a/bareos/fuse/node/directory.py +++ b/bareos/fuse/node/directory.py @@ -28,7 +28,8 @@ class Directory(Base): result = list(self.defaultdirs) + [ str(i) for i in self.subnodes.keys() ] else: if path.get(0) in self.subnodes: - result = self.subnodes[path.get(0)].readdir(path.lstrip([path.get(0)]), offset) + topdir = path.shift() + result = self.subnodes[topdir].readdir(path, offset) return result def get_stat(self): diff --git a/bareos/util/path.py b/bareos/util/path.py index 8156fba..373ce6c 100644 --- a/bareos/util/path.py +++ b/bareos/util/path.py @@ -55,21 +55,28 @@ class Path(object): return self.path[index] - def lstrip(self, path=[]): + #def lstrip(self, path=[]): + #""" + #Creates a new Path instance with lstrip components removed from left. + #""" + #result = copy(self) + #result.root = False + #for i in path: + #if result.get(0) == i: + #result.remove(0) + #else: + ## TODO: exception? + #pass + #return result + + def shift(self): """ Creates a new Path instance with lstrip components removed from left. """ - result = copy(self) - result.root = False - for i in path: - if result.get(0) == i: - result.remove(0) - else: - # TODO: exception? - pass + result = self.get(0) + self.remove(0) return result - def is_directory(self): return self.directory |