immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
53.4k stars 2.82k forks source link

[BUG] mobile: modified asset shown twice #6209

Open waclaw66 opened 11 months ago

waclaw66 commented 11 months ago

The bug

Asset that has been modified (even before upload) is shown twice when it's uploaded. The only way how to get rid of that is to remove both.

Nepojmenované

remotelocal (no longer existing file version after modification)
{
"id": 30363,
"remoteId": "a01a1f9f-fdf7-439e-8d44-583dd94b10f6",
"localId": "N/A",
"checksum": "Z4cv6aRIg6hb02a6DH0j7e3koi0=",
"ownerId": -305544828905697455,
"livePhotoVideoId": "N/A",
"stackCount": "0",
"stackParentId": "N/A",
"fileCreatedAt": "2024-01-06 09:44:40.980",
"fileModifiedAt": "2024-01-06 09:45:07.000",
"updatedAt": "2024-01-06 09:45:26.145",
"durationInSeconds": 0,
"type": "AssetType.image",
"fileName": "20240106_094440.jpg",
"isFavorite": false,
"isRemote": true,
"storage": "AssetState.remote",
"width": 4032,
"height": 3024,
"isArchived": false,
"isTrashed": false
}
{
"id": 30362,
"remoteId": "N/A",
"localId": "1000008006",
"checksum": "8sFp9IV2A6a+LnB/8ETmue8Tfp8=",
"ownerId": -305544828905697455,
"livePhotoVideoId": "N/A",
"stackCount": "0",
"stackParentId": "N/A",
"fileCreatedAt": "2024-01-06 09:44:40.000",
"fileModifiedAt": "2024-01-06 09:45:07.000",
"updatedAt": "2024-01-06 09:45:07.000",
"durationInSeconds": 0,
"type": "AssetType.image",
"fileName": "20240106_094440.jpg",
"isFavorite": false,
"isRemote": false,
"storage": "AssetState.local",
"width": 4032,
"height": 3024,
"isArchived": false,
"isTrashed": false
}

The OS that Immich Server is running on

Fedora 39

Version of Immich Server

v.1.91.4

Version of Immich Mobile App

v.1.91.4

Platform with the issue

Your docker-compose.yml content

not relevant

Your .env content

not relevant

Reproduction steps

1. take a photo, view it in Immich
2. modify (e.g. rotate) that photo using external app (e.g. system gallery editor) 
3. that photo has old thumbnail within Immich, although viewing shows rotated content
4. manually upload that photo
5. photo shown twice, uploaded one with icon of empty cloud and correct thumbnail, the second stays the same, wrong thumbnail with cloud strikethrough icon

Additional information

No response

waclaw66 commented 4 months ago

Any update on this very annoying bug? Seems it would help to recalculate hash again before upload.

waclaw66 commented 3 months ago

@jrasm91 why you've remove bug label? I think it's clearly a bug when an asset with the same content is local and remote however shown twice. I can understand when an asset is modified on device after the upload, then those are different. The main problem is that a file hash is calculated only when a file is discovered within Immich, file hash should be recalculated at least before asset is uploaded. @fyfrey seems you made some code around it, what do you think about it, would it be possible to add hashing before upload? It would solve most of problems, when a taken picture is finetuned on the device (rotation, crop, ...).

fyfrey commented 3 months ago

Hashing again when uploading does not solve much (only a specific case). You can edit the file on device after backup and have even worse issues. :-)

We'd probably need write our own platform native code to reliably get notified by the system if any media files were changed and re-hash all affected assets. We are currently using the photo manager library that does not provide such features afaik.

waclaw66 commented 3 months ago

Hashing again when uploading does not solve much (only a specific case). You can edit the file on device after backup and have even worse issues. :-)

It's specific, but covers the main issue, that a new modified file appers twice when it's uploaded. It's very annoying everyday topic and incomprehensible to users. Same file on both sides, but shown twice because local has stale checksum. On the other hand editing after upload should show the asset twice, because it has different checksum. GPhotos also behaves in this way.

We'd probably need write our own platform native code to reliably get notified by the system if any media files were changed and re-hash all affected assets. We are currently using the photo manager library that does not provide such features afaik.

That would help, however it's much more complex than my proposed fix.

fyfrey commented 3 months ago

Would be good to know if a file has been changed without hashing it again. Does modifying the image alter it's modified date in the Android MediaStore? Photo manager extracts this value and we can check if a modified date is newer than that value in our database. That be much preferable to blindly hashing everything. As a bonus, we could also use it to detect changes after upload.