volume prefix should always end with /

This commit is contained in:
j 2013-04-29 15:36:11 +02:00
parent bd57f5b86f
commit ed5afd667c

View file

@ -381,7 +381,7 @@ class Client(object):
name = args[0] name = args[0]
path = args[1] path = args[1]
if not path.endswith('/'): if not path.endswith('/'):
path = path+'/' path += '/'
if os.path.isdir(path): if os.path.isdir(path):
if name in self._config['volumes']: if name in self._config['volumes']:
print "updated %s to %s" % (name, path) print "updated %s to %s" % (name, path)
@ -466,7 +466,8 @@ class Client(object):
for name in self._config['volumes']: for name in self._config['volumes']:
path = self._config['volumes'][name] path = self._config['volumes'][name]
path = os.path.normpath(path) path = os.path.normpath(path)
if not path.endswith('/'):
path += '/'
if os.path.exists(path): if os.path.exists(path):
files += self.files(path)['info'] files += self.files(path)['info']
else: else:
@ -644,6 +645,8 @@ class Client(object):
def files(self, prefix): def files(self, prefix):
if not prefix.endswith('/'):
prefix += '/'
conn, c = self._conn() conn, c = self._conn()
files = {} files = {}
files['info'] = {} files['info'] = {}
@ -661,7 +664,7 @@ class Client(object):
files['info'][oshash] = info files['info'][oshash] = info
files['files'].append({ files['files'].append({
'oshash': oshash, 'oshash': oshash,
'path': path[len(prefix)+1:], 'path': path[len(prefix):],
'atime': row[3], 'atime': row[3],
'ctime': row[4], 'ctime': row[4],
'mtime': row[5], 'mtime': row[5],