Fix the bug that collides the hash if identical images

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-07-19 00:16:29 -03:00
parent 44ff390695
commit 9e4b08234f
3 changed files with 22 additions and 5 deletions
@@ -63,10 +63,16 @@ class AddPhotoModal(Screen):
async def _async_create_photo(self, photo_data: dict):
"""Creates a new photo asynchronously using PhotoService"""
try:
service_manager = self.app.service_manager
photo_service = service_manager.get_photo_service()
if photo_service.check_photo_by_hash(photo_service.hash_file(photo_data["filepath"]),self.diary_id):
self.notify("Photo already exists in database", severity="error")
return
new_photo = photo_service.create(
filepath=Path(photo_data["filepath"]),
name=photo_data["name"],