Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed folders use old name (Offline Asset Removal does not work) #78

Open
nothing2obvi opened this issue Dec 1, 2024 · 9 comments
Open

Comments

@nothing2obvi
Copy link

nothing2obvi commented Dec 1, 2024

I could really use some help on this, please.

For my immich_server container, the volume mapping for the external library is as follows:

/ExtHDD/External-Libraries:/usr/src/app/external:ro

Based on /ExtHDD/External-Libraries/Album1, Immich Folder Album Creator made these albums:

Album1 - SubfolderA
Album1 - SubfolderB
Album1 - SubfolderC

I then deleted all of the albums using the DELETE_ALL feature.

On my Mac, I then renamed /ExtHDD/External-Libraries/Album1 to /ExtHDD/External-Libraries/Album2

So when I run Immich Folder Album Creator, I expect to get:

Album2 - SubfolderA
Album2 - SubfolderB
Album2 - SubfolderC

However, when I do a dry-run, it says that the albums to be created are:

Album1 - SubfolderA
Album1 - SubfolderB
Album1 - SubfolderC

It's not picking up the new name, Album2.

The dry-run command I'm running is:

docker run -e API_URL="http://10.0.0.85:2283/api/" -e API_KEY="apikeyhere" -e ROOT_PATH="/usr/src/app/external" -e ALBUM_LEVELS="5" -e ALBUM_SEPARATOR=" - " -e FIND_ASSETS_IN_ALBUMS="1" -e FIND_ARCHIVED_ASSETS="1" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh

I also tried it with --force-recreate, but it didn't help. I also tried it with -e SYNC_MODE="2" but it didn't help.

Interestingly, if I run:

docker exec immich_server ls /usr/src/app/external

The albums listed are:

Album2
Reference
Scans
Vacation

So if the immich_server container views the folder with the new name,Album2, I'm not sure why Immich Folder Album Creator is still naming it Album1.

I also tried it on my other Mac, with a different Immich instance, but instead of deleting the albums I just renamed one folder and did a dry-run. Immich Folder Album Creator still uses the old folder name.

Any ideas why? I've tried several things: upgrading to the latest MacOS, clearing the Mac directory cache and restarting the Mac, deleting all Mac cache files and restarting the Mac, restarting the Docker daemon, restarting OrbStack, completely uninstalling then reinstalling OrbStack, and using Docker Desktop instead. But I get the same result.

I'd really appreciate any help. This is kind of driving me nuts. Thank you!

@Salvoxia
Copy link
Owner

Salvoxia commented Dec 1, 2024

This script gets assets paths directly from the Immich API. So if the script doesn't pick up the new folder names, Immich does not provide them.
You might have to trigger a rescan of your external library in Immich. This should cause all assets previously imported from the Album1 folder to be moved to the trash bin, since they are no longer available under the path Immich originally found them under, but Immich should also pick up the assets in Album2 folder.
You can then clear the trash to make Immich forget the offline assets. When running the script after that, it should pick up Album2.
Also refer to the readme section Dealing with external library changes for info on how to automate this.

@nothing2obvi
Copy link
Author

nothing2obvi commented Dec 1, 2024

Thanks for that; things make sense now. I rescanned the external library, waited a few hours until the logs were just doing facial detection stuff, then did a dry-run:

docker run -e API_URL="http://10.0.0.85:2283/api/" -e API_KEY="apikeyhere" -e ROOT_PATH="/usr/src/app/external" -e ALBUM_LEVELS="5" -e ALBUM_SEPARATOR=" - " -e FIND_ARCHIVED_ASSETS="1" -e SYNC_MODE="2" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh

And the proposed album list is:

Album1 - SubfolderA
Album1 - SubfolderB
Album1 - SubfolderC
Album2 - SubfolderA
Album2 - SubfolderB
Album2 - SubfolderC

It's great that it's now detecting Album2, but why is Album1 still there? Did I maybe do it too early?

@nothing2obvi
Copy link
Author

I thought maybe running the actual job would have the desired result, so I ran this command:

docker run -e API_URL="http://10.0.0.85:2283/api/" -e API_KEY="apikeyhere" -e ROOT_PATH="/usr/src/app/external" -e ALBUM_LEVELS="5" -e UNATTENDED="1" -e ALBUM_SEPARATOR=" - " -e FIND_ASSETS_IN_ALBUMS="1" -e FIND_ARCHIVED_ASSETS="1" -e SYNC_MODE="2" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh

The resulting albums were the same:

Album1 - SubfolderA
Album1 - SubfolderB
Album1 - SubfolderC
Album2 - SubfolderA
Album2 - SubfolderB
Album2 - SubfolderC

@nothing2obvi
Copy link
Author

nothing2obvi commented Dec 2, 2024

I scanned the external library, waited 4-5 hours, checked to see there was nothing about it in the logs (no jobs running either), ran the "Library" job, let it complete, attempted to empty the trash (there was nothing there), and ran this dry-run command:

docker run -e API_URL="http://10.0.0.85:2283/api/" -e API_KEY="apikeyhere" -e ROOT_PATH="/usr/src/app/external" -e ALBUM_LEVELS="5" -e ALBUM_SEPARATOR=" - " -e FIND_ASSETS_IN_ALBUMS="1" -e FIND_ARCHIVED_ASSETS="1" -e SYNC_MODE="2" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh

The result is the same:

Album1 - SubfolderA
Album1 - SubfolderB
Album1 - SubfolderC
Album2 - SubfolderA
Album2 - SubfolderB
Album2 - SubfolderC

What am I doing wrong?

Does it matter that I'm also using the Immich Remove Offline Files script?

I'm on Immich v1.121.0, btw.

@Salvoxia
Copy link
Owner

Salvoxia commented Dec 2, 2024

Actually I was thinking that this has to do with offline files. The way Immich handles offline files and its removal changed a couple of versions ago, not sure if the linked script still works as it should. But here's the good news: The Immich Folder Album Creator can do the same ;) The README section about dealing with external library changes linked above details how it works: By setting environment variable SYNC_MODE to 2, the script will delete all assets from Immich that are marked as offline, and the remove all empty albums that might be left behind by this.
This happens at the end of each run, so to get rid of offline assets you first might need to call it with a purposefully non-existant ROOT_PATH once, then run it again with the desired settings.

The script will log if there are any offline assets to remove and how many. Please make sure to check that output.

@nothing2obvi
Copy link
Author

nothing2obvi commented Dec 2, 2024

Thanks for your reply. Just did that with a fake ROOT_PATH:

level=INFO msg=No offline assets found!

Did the dry-run with this command:

docker run -e API_URL="http://10.0.0.85:2283/api/" -e API_KEY="apikeyhere" -e ROOT_PATH="/usr/src/app/external" -e ALBUM_LEVELS="5" -e ALBUM_SEPARATOR=" - " -e FIND_ASSETS_IN_ALBUMS="1" -e FIND_ARCHIVED_ASSETS="1" -e SYNC_MODE="2" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh

Got the same result:

Album1 - SubfolderA
Album1 - SubfolderB
Album1 - SubfolderC
Album2 - SubfolderA
Album2 - SubfolderB
Album2 - SubfolderC

Did the dry-run with this command (no FIND_ARCHIVED_ASSETS):

docker run -e API_URL="http://10.0.0.85:2283/api/" -e API_KEY="apikeyhere" -e ROOT_PATH="/usr/src/app/external" -e ALBUM_LEVELS="5" -e ALBUM_SEPARATOR=" - " -e FIND_ASSETS_IN_ALBUMS="1" -e SYNC_MODE="2" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh

Got this ✅:

Album2 - SubfolderA
Album2 - SubfolderB
Album2 - SubfolderC

I forgot that for all of the Album1 assets, I had archived them. Then I deleted those albums and changed the name to Album2.

My question is: Since I changed the name from Album1 to Album2 and did an external library scan, why aren't the Album1 assets considered offline? As I stated above, no offline assets were found. I realize that because I had archived the Album1 assets before I deleted the Album1 albums, those assets are included in the run if I include FIND_ARCHIVED_ASSETS. However, using SYNC_MODE="2", shouldn't all of the Album1 assets (which should be offline) and then the Album1 albums themselves get deleted at the end of the run, using this command (same as the first one in this comment)?:

docker run -e API_URL="http://10.0.0.85:2283/api/" -e API_KEY="apikeyhere" -e ROOT_PATH="/usr/src/app/external" -e ALBUM_LEVELS="5" -e ALBUM_SEPARATOR=" - " -e FIND_ASSETS_IN_ALBUMS="1" -e FIND_ARCHIVED_ASSETS="1" -e SYNC_MODE="2" salvoxia/immich-folder-album-creator:latest /script/immich_auto_album.sh

Or am I misunderstanding something?

@Salvoxia
Copy link
Owner

Salvoxia commented Dec 2, 2024

My question is: Since I changed the name from Album1 to Album2 and did an external library scan, why aren't the Album1 assets considered offline?

That is indeed the question and not in line with what Immich should do. During my quick test yesterday I also was surprised that it did not detect these images as offline, which makes me think there might be a bug in Immich introduced in one of the latest version. But that requires more investigation before opening an issue with Immich itself (e.g. rolling back to an earlier version to see when/if the behavior changes). The change in dealing with offline assets was introduced with version 1.116.0.

@Salvoxia
Copy link
Owner

Salvoxia commented Dec 2, 2024

Did some more testing.
My quick tests from yesterday actually tested a different use case: I renamed a folder that was part of the external library's import path. Immich does not seem to consider assets offline for which the import path is no longer valid, presumably because it relies on watching the import paths to detect when assets are gone. This could be considered a bug.
During today's tests I renamed a folder inside the import path, which is what you did. After a page reload Immich recognized the assets were gone, the album was empty and the images were shown in the trash. So no sure why its not working for you, even after a manual library rescan. For me, it worked without a manual rescan, since library watching is enabled (this feature is marked as experimental, so maybe it's not working properly on Mac?).
However, Folder Album Creator did not pick up the offline assets. It seems during the last couple of releases the API was changed so the method for finding offline assets no longer works - which seems like a bug. I reported it here, I think the more attention this gets the better.

@nothing2obvi
Copy link
Author

Thanks for following up on this. Not much, but I also commented on an existing issue.

@Salvoxia Salvoxia pinned this issue Jan 4, 2025
@Salvoxia Salvoxia changed the title Renamed folders use old name Renamed folders use old name (Offline Asset Removal does not work) Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants