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
|
||||
|
||||
# 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:
|
||||
m = hashlib.md5()
|
||||
while True:
|
||||
data = fh.read(8192)
|
||||
if not data:
|
||||
break
|
||||
m.update(data)
|
||||
metadata["md5_hash"] = m.hexdigest()
|
||||
except (OSError, IOError) as e:
|
||||
raise e
|
||||
with open(filename, 'rb') as fh:
|
||||
m = hashlib.md5()
|
||||
while True:
|
||||
data = fh.read(8192)
|
||||
if not data:
|
||||
break
|
||||
m.update(data)
|
||||
metadata["md5_hash"] = m.hexdigest()
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue