mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 02:36:44 +00:00
Detect broken Pillow (close #135)
This commit is contained in:
@@ -898,8 +898,11 @@ def detectCorruption(tmpPath, orgPath):
|
|||||||
img.verify()
|
img.verify()
|
||||||
img = Image.open(path)
|
img = Image.open(path)
|
||||||
img.load()
|
img.load()
|
||||||
except Exception:
|
except Exception as err:
|
||||||
rmtree(os.path.join(tmpPath, '..', '..'), True)
|
rmtree(os.path.join(tmpPath, '..', '..'), True)
|
||||||
|
if 'decoder' in err and 'not available' in err:
|
||||||
|
raise RuntimeError('Pillow was compiled without JPG and/or PNG decoder.')
|
||||||
|
else:
|
||||||
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
|
raise RuntimeError('Image file %s is corrupted.' % pathOrg)
|
||||||
else:
|
else:
|
||||||
os.remove(os.path.join(root, name))
|
os.remove(os.path.join(root, name))
|
||||||
|
|||||||
Reference in New Issue
Block a user