fix ox.file

This commit is contained in:
j 2014-09-30 21:30:25 +02:00
parent ec252440d9
commit 46278349e3

View file

@ -49,7 +49,6 @@ def _get_file_cache():
def cache(filename, type='oshash'):
conn = sqlite3.connect(_get_file_cache(), timeout=10)
conn.text_factory = str
conn.row_factory = sqlite3.Row
if not cache.init:
@ -92,7 +91,6 @@ cache.init = None
def cleanup_cache():
conn = sqlite3.connect(_get_file_cache(), timeout=10)
conn.text_factory = str
conn.row_factory = sqlite3.Row
c = conn.cursor()
c.execute('SELECT path FROM cache')
@ -108,8 +106,8 @@ def sha1sum(filename, cached=False):
if cached:
return cache(filename, 'sha1')
sha1 = hashlib.sha1()
with open(filename) as f:
for chunk in iter(lambda: f.read(128*sha1.block_size), ''):
with open(filename, 'rb') as f:
for chunk in iter(lambda: f.read(128*sha1.block_size), b''):
sha1.update(chunk)
return sha1.hexdigest()