only scan/sync active volumes

This commit is contained in:
j 2012-11-01 12:53:02 +01:00
parent 9e8b14bd7f
commit 0ce16b5c2b

View file

@ -303,11 +303,20 @@ class Client(object):
self._config['volumes'][name] = path
def scan(self, args):
print "checking for new files ..."
def active_volumes(self):
volumes = {}
for name in sorted(self._config['volumes']):
path = self._config['volumes'][name]
path = os.path.normpath(path)
if os.path.exists(path):
volumes[name] = path
return volumes
def scan(self, args):
print "checking for new files ..."
volumes = self.active_volumes()
for name in sorted(volumes):
path = volumes[name]
conn, c = self._conn()
c.execute('SELECT path FROM file WHERE path LIKE ? AND deleted < 0', ["%s%%"%path])
known_files = [r[0] for r in c.fetchall()]
@ -383,21 +392,9 @@ class Client(object):
return
conn, c = self._conn()
volumes = {}
for name in sorted(self._config['volumes']):
path = self._config['volumes'][name]
path = os.path.normpath(path)
volumes[name] = {}
volumes[name]['path'] = path
if os.path.exists(path):
volumes[name]['available'] = True
else:
volumes[name]['available'] = False
volumes = self.active_volumes()
for name in sorted(volumes):
if volumes[name]['available']:
prefix = volumes[name]['path']
prefix = volumes[name]
files = self.files(prefix)
post = {}
post['files'] = files['files']