inform about file size

This commit is contained in:
Ville Rantanen
2016-12-22 09:02:56 +02:00
parent badc2a66e0
commit bf2f587a2b

View File

@@ -98,14 +98,17 @@ def add_recurse(options):
return return
def add_single(conn,filename,change=False,hash=None,minsize=0,fullfile=False): def add_single(conn,filename,change=False,hash=None,minsize=0,fullfile=False):
try:
print "%(f)s" % {'f':filename} fsize=os.path.getsize(filename)
hsize=humanize_size(fsize)
except IOError:
hsize=""
print("%s (%s)"%(filename,hsize))
db=conn.cursor() db=conn.cursor()
try: try:
if hash==None: if hash==None:
hash=get_md5(filename,fullfile) hash=get_md5(filename,fullfile)
ftime=os.path.getmtime(filename) ftime=os.path.getmtime(filename)
fsize=os.path.getsize(filename)
mime=MIME.file(filename.encode('UTF-8')) mime=MIME.file(filename.encode('UTF-8'))
except IOError: except IOError:
print("File '%s' not found. Bad link?"%(filename,)) print("File '%s' not found. Bad link?"%(filename,))