warn about files not withint folder depth

This commit is contained in:
j 2013-02-04 18:38:02 +05:30
parent 06428673c8
commit 70605926ec

View file

@ -178,6 +178,7 @@ class Client(object):
r = self.api.signin(username=self._config['username'], password=self._config['password']) r = self.api.signin(username=self._config['username'], password=self._config['password'])
if r['status']['code'] == 200 and not 'errors' in r['data']: if r['status']['code'] == 200 and not 'errors' in r['data']:
self.user = r['data']['user'] self.user = r['data']['user']
self.folderdepth = r['data']['site'].get('folderdepth', 3)
else: else:
self.user = False self.user = False
print '\nlogin failed! check config\n\n' print '\nlogin failed! check config\n\n'
@ -317,6 +318,8 @@ class Client(object):
volumes = self.active_volumes() volumes = self.active_volumes()
for name in sorted(volumes): for name in sorted(volumes):
path = volumes[name] path = volumes[name]
if not path.endswith('/'):
path += '/'
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()]
@ -346,6 +349,16 @@ class Client(object):
c.execute('UPDATE file SET deleted=? WHERE path=?', (deleted, f)) c.execute('UPDATE file SET deleted=? WHERE path=?', (deleted, f))
conn.commit() conn.commit()
ignored=[]
for f in files:
f = f[len(path):]
if len(f.split('/')) == self.folder_depth and not 'Versions' in f or 'Extras' in f:
ignored.append(f)
if ignored:
example = self.folder_depth == 4 and 'L/Last, First/Title (Year)/Title.avi' or 'T/Title/Title.dv'
print 'The following files do not conform to the required folder structure and will be ignored. only files like this are synced:\n\t%s' % example
print '\n'.join(ignored)
print "scanned volume %s: %s files, %s new, %s deleted" % ( print "scanned volume %s: %s files, %s new, %s deleted" % (
name, len(files), len(new_files), len(deleted_files)) name, len(files), len(new_files), len(deleted_files))