duplicate: close file context after read
This commit is contained in:
parent
989c1803fd
commit
3350dd2f8d
1 changed files with 2 additions and 1 deletions
|
|
@ -54,7 +54,8 @@ def find_duplicate(gallery):
|
||||||
duplicate = {}
|
duplicate = {}
|
||||||
|
|
||||||
for photo in gallery.photos.all():
|
for photo in gallery.photos.all():
|
||||||
h0 = hashlib.sha256(photo.image.read()).digest()
|
with photo.image.open("rb") as f:
|
||||||
|
h0 = hashlib.sha256(f.read()).digest()
|
||||||
if h0 not in non_duplicate:
|
if h0 not in non_duplicate:
|
||||||
# Photo is not a duplicate
|
# Photo is not a duplicate
|
||||||
non_duplicate[h0] = photo
|
non_duplicate[h0] = photo
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue