Skip to content

Commit

Permalink
checks for duplicate images
Browse files Browse the repository at this point in the history
  • Loading branch information
actlikewill committed Sep 30, 2024
1 parent 3348183 commit 4f2f951
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions peachjam/adapters/indigo.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,17 @@ def download_and_save_document_images(self, document, created_document):
r = self.client_get(result["url"])
file.write(r.content)

Image.objects.create(
img, new_img = Image.objects.get_or_create(
document=created_document,
file=File(file, name=result["filename"]),
mimetype=result["mime_type"],
filename=result["filename"],
size=result["size"],
defaults={
"file": File(file, name=result["filename"]),
"mimetype": result["mime_type"],
"size": result["size"],
},
)
if not new_img:
logger.info(f"image {img.filename} already exists")

logger.info(f"Downloaded image(s) for {created_document}")

Expand Down

0 comments on commit 4f2f951

Please sign in to comment.