immich icon indicating copy to clipboard operation
immich copied to clipboard

[BUG] Deleting duplicate pictures lead to negative remainder counter

Open ytzelf opened this issue 2 years ago • 21 comments

Describe the bug After adding the Camera album on my Android phone to Immich I deleted numerous pictures from another app (duplicate finder). The assets remained in the cloud and the dashboard now show a negative Remainder.

To Reproduce Steps to reproduce the behavior:

  1. Add an album to Backup Albums on the mobile app with numerous duplicate pictures
  2. Wait for backup to be finished
  3. Batch delete duplicate pictures in that album from a 3rd party app
  4. Pictures are not on the phone anymore but still backed up leading to a negative Remainder counter

Expected behavior Some kind of purging mechanism where pictures that don't live on the phone are deleted from the server.

Screenshots If applicable, add screenshots to help explain your problem.

System

  • Phone OS Android: 12
  • Server Version: 1.35
  • Mobile App Version: 1.35

Additional context Add any other context about the problem here.

ytzelf avatar Nov 14 '22 21:11 ytzelf

confirmed

alextran1502 avatar Nov 15 '22 05:11 alextran1502

I don't know to what extent you want the two way sync to be authoritative but I'd expect the phone to be the single source of trust for the pictures and those deleted from there should be deleted from the server, either real time or through a pruning cron-job type process that makes sure that server is sync'd to phone daily or so.

ytzelf avatar Nov 15 '22 10:11 ytzelf

@ytzelf I don't think you want that because then if you remove photos or videos on the phone to have more space to take more photos they will be also deleted on the server. Which is not what backing up means.

alextran1502 avatar Nov 15 '22 14:11 alextran1502

OK then i'm not sure how to work around that issue.

What I could see working is 1/ Select all items in backups and not on the phone (separate issue - easily selecting all items, items for a specific date range or items based on their storage location is needed) 2/ Delete these items on the backup location from the mobile app (maybe a delete subdialog on pictures - "delete from phone" and "delete from backup")

If you're fine having pictures on backup that were explicitely deleted from the phone then I'm not sure this is even an issue at all tbh (and the remainder counter can just be max(0, total-uploaded)). Probably more a matter of being able to view, quickly select, and delete quickly these pictures.

ytzelf avatar Nov 15 '22 14:11 ytzelf

May be related to this issue but I got a negative number after closing and re-opening the app, no deleting needed.

gh3597 avatar Nov 20 '22 12:11 gh3597

Same proplem for me.

spupuz avatar Nov 20 '22 20:11 spupuz

May be related to this issue but I got a negative number after closing and re-opening the app, no deleting needed.

I just left my phone to do it's first backup on a freshly new immich server during the night and I got this.

Screenshot_20221221-074424

SpecialAro avatar Dec 21 '22 07:12 SpecialAro

May be related to this issue but I got a negative number after closing and re-opening the app, no deleting needed.

I just left my phone to do it's first backup on a freshly new immich server during the night and I got this.

Screenshot_20221221-074424

Beside backup up from the phone, did by chance upload anything else from the web or from the CLI? If you go on the web and hover on the question mark next to the Photos button, what is the sum of the photos and videos count?

alextran1502 avatar Dec 21 '22 13:12 alextran1502

May be related to this issue but I got a negative number after closing and re-opening the app, no deleting needed.

Beside backup up from the phone, did by chance upload anything else from the web or from the CLI?

Nop, just through this phone.

If you go on the web and hover on the question mark next to the Photos button, what is the sum of the photos and videos count?

image

This? It is exactly 1913 (as shows on the phone)

SpecialAro avatar Dec 21 '22 13:12 SpecialAro

Is this related to Live Photos being stored as two parts (and showing up in the count as two separate assets)? Is there a way for you to easily tell how many live photos you have?

Ideally the backup count should be how many assets are left to backup, which is unrelated to how many are on the server or have previously been backed-up to the server. It should be something like: count(assets from selected albums on device) - count(where on device asset is in list of assets on the server).

jrasm91 avatar Dec 21 '22 14:12 jrasm91

Is this related to Live Photos being stored as two parts

Wouldn't have thought so as I have zero live photos.

All I did when I got this initially was to install the app and let it sync. No other upload methods used at that point in time.

gh3597 avatar Dec 21 '22 14:12 gh3597

Is this related to Live Photos being stored as two parts

Wouldn't have thought so as I have zero live photos.

All I did when I got this initially was to install the app and let it sync. No other upload methods used at that point in time.

I think you have some duplicate photos or videos and the app doesn't handle the duplication count correctly. Can you help me confirm if you have some duplicate photos or videos in your library?

alextran1502 avatar Dec 23 '22 04:12 alextran1502

Is this related to Live Photos being stored as two parts

Wouldn't have thought so as I have zero live photos. All I did when I got this initially was to install the app and let it sync. No other upload methods used at that point in time.

I think you have some duplicate photos or videos and the app doesn't handle the duplication count correctly. Can you help me confirm if you have some duplicate photos or videos in your library?

Just quickly looked through all my photos and I can't find any duplicates (at least the file names are always different).

SpecialAro avatar Jan 04 '23 13:01 SpecialAro

I think you have some duplicate photos or videos and the app doesn't handle the duplication count correctly. Can you help me confirm if you have some duplicate photos or videos in your library?

Not as far as I'm aware. Depends on what the criteria is? File names will all be unique, anything "duplicate" will be things like downloaded items that have no or minimal metadata?

Just opened the app (not logged in for a while as the server/app was not the same version so have been "locked out" until I could update the server) and using foreground backup it is now backing up -43 assets, and this number is decreasing i.e. first image uploaded then remainder is -44 etc. None of the current photos are duplicates and certainly not all of them.

gh3597 avatar Jan 17 '23 12:01 gh3597

I have also noticed this issue on Android.

Screenshot_20230128-201856.png

samip5 avatar Jan 28 '23 18:01 samip5

Dropping by to share a finding.

  • I noticed that on my partner's device, the negative count -1 coincides with the exact number of files stuck in the upload subfolder (which was corrupted due to incomplete/failed upload).
  • However that number for my device -30 is still much larger than the number of stuck files 5.
    • I cannot explain why but perhaps I deleted some files after they were uploaded
  • Note that failed photos/videos are just stuck there. I verified that the intended files were (re)uploaded successfully and were placed in the right folders in the library subfolder.

My hypothesis is that there is a possibility that files stuck in the upload folder may count towards library size and therefore contribute towards this negative photo count issue.


My two cents on source of truth and this issue overall:

  • I agree with @alextran1502 in that the device should not be the single source of truth, but the server is.
  • In the event that some assets were deleted from the devices, they should still exist in the library (server).
    • I really dislike the approach that the big G uses where deletion on the App or Web will result in deletion of that asset across all devices.
    • I have some really huge videos that should not belong to any device but the server. Going through the process of deleting just on the device and not syncing that deletion was a huge pain.
    • That annoyance subconsciously restricted my use of videos in recording memories, which is a huge waste.
  • Perhaps a mitigation here would be
    • Correctly display statistics on assets that only exist on the server
      • Need to fix logic on counting assets coming from each device
      • If the asset does come from the device in question, don't count it as Remainder
    • Have a filtered view for assets that do not exist locally on the device in question

ikaruswill avatar Apr 09 '23 02:04 ikaruswill

Just encountered this bug too, on Android. I did not manually delete any photos, but overnight the app has ended up with Remainder: -9, and I have a permanent notification saying Backing up your assets... 42% (3/7).

Looking at my library, the two newest photos have a cloud icon with a line through it, which I take to mean that they aren't backed up (looking at progres logs, looks like I've encountered https://github.com/immich-app/immich/issues/2547 too). Perhaps worth noting that I hadn't launched the app in a while. I launched it this morning after I saw the stuck notification, got a message about a server update, updated the server but the problem remains.

There were 10 files in the /usr/src/app/upload/upload/<uid> folder, I deleted them but that hasn't addressed the problem.

ameyp avatar May 24 '23 16:05 ameyp

Using iOS client:

I understand that the counter just subtracts 'Backup' number from 'Total' that's on device.

My suggestion would be to compare the last backed up photo/video ID with the one on device and then count from there how many more photos/videos are to be backed up.

bigbeka avatar May 27 '23 09:05 bigbeka

Wanted to leave a note that I just experienced this as well on iOS. Not sure if you need me to help gather information or not for you.

nocomputeruser avatar May 29 '23 17:05 nocomputeruser

Seem to have the same problem:

Screenshot_2023-06-03-16-49-36-682_app alextran immich

Workflow: I started by uploading images from my new phone using immich - after deciding it's a great tool I installed immich on my old phone to upload these pictures, too. Maybe that's the problem?! ...

mtettke123 avatar Jun 03 '23 14:06 mtettke123

Same issue. Fresh setup and was backing up ~8000 photos/videos on my Android phone. I had made changes during the process, adding 2 more albums, and restarting my phone. At one point the Total started showing ~5000 even though camera still had 8000 assets.

I was able to resolve the issue by deleting the app's cache and data. Upon login to a fresh app, I reselected the backup albums and the Total is now correct, matching Backup.

mmorys avatar Jun 23 '23 12:06 mmorys

Same issue. Fresh setup and was backing up ~8000 photos/videos on my Android phone. I had made changes during the process, adding 2 more albums, and restarting my phone. At one point the Total started showing ~5000 even though camera still had 8000 assets.

I was able to resolve the issue by deleting the app's cache and data. Upon login to a fresh app, I reselected the backup albums and the Total is now correct, matching Backup.

Thank you, this workaround fixes the issue for me also :)

d3473r avatar Jul 25 '23 20:07 d3473r

Same issue. Fresh setup and was backing up ~8000 photos/videos on my Android phone. I had made changes during the process, adding 2 more albums, and restarting my phone. At one point the Total started showing ~5000 even though camera still had 8000 assets.

I was able to resolve the issue by deleting the app's cache and data. Upon login to a fresh app, I reselected the backup albums and the Total is now correct, matching Backup.

That ... did it for me as well. Thanks a lot it was somewhat irking ^^

ytzelf avatar Jul 26 '23 10:07 ytzelf

I freshly installed immich two times, to see if the error was on my side, but i can confirm this bug:

  1. Install Immich server
  2. Install Android app
  3. Select "Camera" Folder to upload (not much, ~400 Photos)
  4. Let the phone sit for a while to finish
  5. Encounter this bug (numbers seem to differ each installation)

Screenshot_20230831-174226_Immich(1)

//edit: deleting cache does not help in my case. maybe a full wipe of the app-data would ...

NextBlaubeere avatar Aug 31 '23 16:08 NextBlaubeere

I can confirm that this does happen with the Android app with a freshly installed server and that deleting app cache and data doesn't really solve the issue

lead0r avatar Sep 08 '23 13:09 lead0r

I was able to reproduce getting a negative number following these steps (I am on ios).

  1. Have auto-upload in foreground on
  2. Start app and let it upload new pictures
  3. Don't migrate away from Photos tab, go to one of the new pictures that was uploaded. You can still click the "upload asset" button. Click it and confirm upload
  4. The asset will be uploaded again and now the remaining will be "negative" indefinitely.

jrnewell avatar Sep 18 '23 15:09 jrnewell

Deleting app data and cached on Android worked for me

vitor-alves avatar Oct 30 '23 15:10 vitor-alves

I have the same problem. Mine is -1677. I have theorized that what caused it was initially having the "Recent" category selected when I enabled auto-backup. Items in that category will overlap items in other selected categories/locations. So once I realized and deselected it, there were already "extra" items uploaded that the app now sees as a negative count. More items auto-uploaded than the app is set for.

Deleting the app data (Android) and setting up auto-backup again did reset everything for me.

Tyree avatar Nov 20 '23 12:11 Tyree

That might be what caused it for you, but I just selected the folders (not including "recent"), let it sync, and found the negative number when I came back. Somewhere along the way, the "total" is getting way off track.

Screenshot_20231202-074741

hobesman avatar Dec 02 '23 15:12 hobesman

Im not sure about official team's position on this, but IMO it could be solved by checking # of images that were shot after latest upload timestamp

avdept avatar Feb 21 '24 19:02 avdept