properly handle files in unsupported formats. print list of files that will not be syned due to format issues

This commit is contained in:
j 2014-04-15 12:46:48 +02:00
parent 72b5643e68
commit 77096ddb17

View file

@ -351,21 +351,17 @@ class Client(object):
modified = time.mktime(time.localtime())
created = modified
sql = 'SELECT atime, ctime, mtime, size, created FROM file WHERE deleted < 0 AND path=?'
sql = 'SELECT atime, ctime, mtime, size, created, info FROM file WHERE deleted < 0 AND path=?'
c.execute(sql, [path])
stat = os.stat(path)
for row in c:
if stat.st_atime == row[0] and stat.st_ctime == row[1] and stat.st_mtime == row[2] and stat.st_size == row[3]:
created = row[4]
info = json.loads(row[5])
update = False
break
if update or rescan:
info = utils.avinfo(path, cached=not rescan)
'''
if 'error' in info or info['size'] == 0:
#print info
return False
'''
if info['size'] > 0:
oshash = info['oshash']
sha1 = None
@ -375,7 +371,7 @@ class Client(object):
c.execute(u'INSERT OR REPLACE INTO file values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
t)
conn.commit()
return True
return 'error' not in info
def get_resolution(self, info):
height = info['video'][0]['height'] if info.get('video') else None
@ -510,7 +506,7 @@ class Client(object):
files = list(set(files) - set(unknown))
for f in files:
if not self.scan_file(f):
if not self.scan_file(f, rescan):
unsupported.append(f)
if unknown:
@ -521,7 +517,6 @@ class Client(object):
print '\n\t'.join([f[len(path):].encode('utf-8') for f in unknown])
print ''
'''
if unsupported:
files = list(set(files) - set(unsupported))
print 'The following files are in an unsupported format and will not be synced:'
@ -529,6 +524,7 @@ class Client(object):
print '\n\t'.join([f[len(path):] for f in unsupported])
print ''
'''
'''
deleted_files = filter(lambda f: f not in files, known_files)
new_files = filter(lambda f: f not in known_files, files)
@ -808,17 +804,18 @@ class Client(object):
path = row[0]
oshash = row[1]
info = json.loads(row[2])
for key in ('atime', 'ctime', 'mtime', 'path'):
if key in info:
del info[key]
files['info'][oshash] = info
files['files'].append({
'oshash': oshash,
'path': path[len(prefix):],
'atime': row[3],
'ctime': row[4],
'mtime': row[5],
})
if not 'error' in info:
for key in ('atime', 'ctime', 'mtime', 'path'):
if key in info:
del info[key]
files['info'][oshash] = info
files['files'].append({
'oshash': oshash,
'path': path[len(prefix):],
'atime': row[3],
'ctime': row[4],
'mtime': row[5],
})
return files
def clean(self, args):