diff --git a/files/file_list.py b/files/file_list.py index 21eadc6..51b7317 100755 --- a/files/file_list.py +++ b/files/file_list.py @@ -17,6 +17,7 @@ MINSIZE=0 MIME=magic.open(magic.MAGIC_NONE) #MIME=magic.open(magic.MAGIC_MIME) MIME.load() +ANIM=['-','\\','|','/','-','_','_'] def setup_options(): parser=ArgumentParser(description="Maintains the list of images sqlite file") @@ -106,11 +107,11 @@ def add_single(conn,filename,change=False,hash=None,minsize=0,fullfile=False): fsize=os.path.getsize(filename) mime=MIME.file(filename.encode('UTF-8')) except IOError: - print("File not found. Bad link?") + print("File '%s' not found. Bad link?"%(filename,)) return except UnicodeDecodeError: mime="NA" - + if change: db.execute("UPDATE list SET date=?, hash=?, size=?, mime=? \ WHERE file=?",(ftime,hash,fsize,mime,filename)) @@ -310,11 +311,16 @@ def get_folder_contents(db,path): def get_md5(filename,fullfile=False): ''' returns content based hash, only first 50Mb is read, unless user wants the whole file ''' if fullfile: - block_size=2**20 + anim_i=0 + block_size=2**24 md5 = hashlib.md5() with open(filename,'rb') as f: for chunk in iter(lambda: f.read(block_size), b''): + sys.stdout.write('\r'+ANIM[anim_i]) + sys.stdout.flush() + anim_i=(anim_i+1)%len(ANIM) md5.update(chunk) + sys.stdout.write('\r') return md5.hexdigest() return hashlib.md5(open(filename,'rb').read(1024*1024*50)).hexdigest()