Allow images to be stored in subdirs and used by templates.

This commit is contained in:
grossmj committed 2021-08-30 16:53:41 +09:30
1 parent 332fa47b50
commit d606553e20
8 files changed
+159 -48

No files matched your search

+3 -2
View File
@@ -273,8 +273,9 @@ async def write_image(
checksum = checksum.hexdigest()
duplicate_image = await images_repo.get_image_by_checksum(checksum)
if duplicate_image:
raise InvalidImageError(f"Image {duplicate_image.filename} with same checksum already exists")
if duplicate_image and os.path.dirname(duplicate_image.path) == os.path.dirname(path):
raise InvalidImageError(f"Image {duplicate_image.filename} with "
f"same checksum already exists in the same directory")
except InvalidImageError:
os.remove(tmp_path)
raise