SAAS-596: Store file size and hash in database
Removed try/except while getting file size and hash
This commit is contained in:
parent
66a6a8f985
commit
cc9e6efbca
1 changed files with 9 additions and 12 deletions
|
@ -99,19 +99,16 @@ class MetadataAnalyzer(Analyzer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Get file size and md5 hash of the file
|
# Get file size and md5 hash of the file
|
||||||
try:
|
metadata["filesize"] = os.path.getsize(filename)
|
||||||
metadata["filesize"] = os.path.getsize(filename)
|
|
||||||
|
|
||||||
with open(filename, 'rb') as fh:
|
with open(filename, 'rb') as fh:
|
||||||
m = hashlib.md5()
|
m = hashlib.md5()
|
||||||
while True:
|
while True:
|
||||||
data = fh.read(8192)
|
data = fh.read(8192)
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
m.update(data)
|
m.update(data)
|
||||||
metadata["md5_hash"] = m.hexdigest()
|
metadata["md5_hash"] = m.hexdigest()
|
||||||
except (OSError, IOError) as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue