fixed bad links file_list

This commit is contained in:
ville rantanen
2014-07-23 09:06:59 +03:00
parent 9144e89a9e
commit 4ba197146b
2 changed files with 15 additions and 9 deletions

View File

@@ -154,14 +154,19 @@ def add_recurse(options):
return
def add_single(conn,filename,change=False,hash=None,minsize=0):
db=conn.cursor()
print "%(f)s" % {'f':filename}
if hash==None:
hash=get_md5(filename)
ftime=os.path.getmtime(filename)
fsize=os.path.getsize(filename)
mime=MIME.file(filename.encode('UTF-8'))
db=conn.cursor()
try:
if hash==None:
hash=get_md5(filename)
ftime=os.path.getmtime(filename)
fsize=os.path.getsize(filename)
mime=MIME.file(filename.encode('UTF-8'))
except IOError:
print("File not found. Bad link?")
return
if change:
db.execute("UPDATE list SET date=?, hash=?, size=?, mime=? \
WHERE file=?",(ftime,hash,fsize,mime,filename))