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