fix(server): Live Photo migration bug when album is in template#25329
fix(server): Live Photo migration bug when album is in template#25329danieldietzler merged 21 commits intoimmich-app:mainfrom
Conversation
…n the loop since the still photo will handle the migration of the video
|
If you need some beta testers, let me know. |
Thanks! feel free to pull this commit I can rebase so it contains the latest versions. I’ve been using this as a mirror seems to work well so far lmk if you face any issues |
Rebased it, should be upto-date with the latest patches, lmk if you face any issues, thanks! |
|
@SimJoSt I tried your template out of curiosity seems to work well! here is the tree of my personal library, doesn't seem to have any live video stragglers as expected |
|
@NikhilAlapati thank you for checking 🙏 My main concern is to fix the current situation and consolidate all files under the same storage label again. |
|
@SimJoSt yea that shouldn't be a problem now. that was happening due to the prod version doesn't fully transfer the metadata(still photo -> motion video). I changed my test storage label to admin_changed_label and the directory structure looks identical as before with the user folder name changed with your template. the old label is no longer there as expected |
|
Nice, then it should be enough to run the storage migration job again to cleanup the file structure. |
There was a problem hiding this comment.
We already have logic for this here https://github.com/immich-app/immich/blob/main/server/src/services/storage-template.service.ts#L159-L167 and here https://github.com/immich-app/immich/blob/main/server/src/services/storage-template.service.ts#L192-L199. Why does that not apply here?
@danieldietzler Those implementations don't work fully for all templates due to Metadata not being attributed to the Live Photo Video from the Still Photo. when handleMigrationSingle runs the result depends on if the motion video gets processed first vs the still photo getting processed first. if the still photo gets processed first then it will migrate the motion video, but when the motion video gets processed by this function later it will be moved back the video to the wrong location since the metadata is not properly attributed Same deal for handleMigration if a still photo gets processed first then the live will be moved correctly however, in future iteration when the live video gets processed it will not be templated properly This issue in the original implementation is fixed by this https://github.com/immich-app/immich/pull/25329/changes#diff-160ca0c92818fe07b15afe84633d23c96c44bf66c97c54bf6d0d25cdaafebadfR279 which uses the still photo(if it's Live) to get the template path, which makes sure they both will be in the same location regardless of the template used |
|
Is there any reason to migrate assets with |
@danieldietzler That's a good point, if we don't queue |
|
@danieldietzler Updated the implementation, much simpler now. Removed the SQL to find still photo from the live photo, removed the complex checks in handleMigration and handleMigrationSingle, and updated unit tests Manual Testing Detailstemplate used: and live photo and still photo in the same folder complex template: Result: migrated correctly with live and still photos in the same folder
|
… database for handleMigration
I am so confused. You don't ever need to get the motion part of a live photo, that's the whole point of this exercise. You also don't seem to be using that query anyways, so I really don't understand that comment |
Hey, I use it here inside handleMigration() and handleMigrationSingle() here the purpose of this query is to get the live asset(When the still is being processed) so it can be passed to moveAsset for migration. You are right we don't want process the live video directly, but we still move it when the still photo is being processed. |
|
Edit: my bad I was lost |
No worries, it's easy to forget the details when you review dozens of PRs per day |
|
Right, this is very similar to |
Refactored |
|
So I am really new to github - this issue has been driving me crazy and it seems there is a fix? So the next steps it to contact the devs to get it implemented? How long is that process normally with open source projects? I apologize for my ignorance. Thank you! |
Hey @JagguRaja, so what you commented on is a "Pull Request" (PR). That's essentially proposing a code change to be merged into the project. As such, Nikhil opened a PR to fix this issue. As you can see in the history if you scroll up, we already went through a couple of rounds of reviews. Once we're happy with the state of the PR, we'll merge it and it will be available in the next release :) |
Thank you for being so patient and answering that with so much detail. Pull requests make a lot of sense now. Thank you again. |
|
Can we incorporate an extra fancy braacket into the code so that users don't need to add an extra "{}" around the album name? For example, if I use "{{album}}/{{y}}-{{MMM}}-{{d}}-{{filename}}" and the album has a special character such as "&" (for example "Hike & Waterfall"), Immich names the folder "Hike To get around this, we need to add another set of brackets so it becomes "{{{album}}}/{{y}}-{{MMM}}-{{d}}-{{filename}}" This names the folder "Hike & Waterfall" as the user intended. Just bringing this up here because I have faced this issue and it seems you are fixing an issue in a similar area so maybe this would be easy to implement while you make the change for live photos. Thanks for the work you are doing on this issue! |
PRs should always be as focused as possible, thus the feature you're asking for should definitely not be implemented here. Feel free to open a feature request for it though if there isn't already one covering that |
danieldietzler
left a comment
There was a problem hiding this comment.
Finally got around to testing this; seems to work well. Thanks!
…ch-app#25329) Co-authored-by: Nikhil Alapati <nikhilalapati@meta.com>



Description
Fix live photo migration bug where if album is in template the live video will not get moved to the album. With this it will be moved with or without an album. This is due to the metadata of the still photo is not being used for the motion part in the migration.
I have previously made this PR #24688 which aimed to fix live photo video parts not getting moved by the storage template properly, that PR fixes the issue only partially. This PR improves upon #24688 by using the same metadata for the Live Video as the Still Photo which will enable Live photo template migration to all storage templates
Fixes # #17668
How Has This Been Tested?
Basic Upload Test Web
Comprehensive Full Library Upload Manual E2E Sanity Check
Screenshots (if appropriate)
Screenshots for Basic Web Upload test
Image shows all assets are uploaded to their albums and organized correctly

Uploads folder empty as expected after migration

Screenshots for Comprehensive Full Library Test
Screenshot shows all assets properly arranged into their respepective albums, no strays without albums

Screenshot shows upload folder empty
Screenshot shows albums correctly visible in web

Checklist:
src/services/uses repositories implementations for database calls, filesystem operations, etc.src/repositories/is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services/)Please describe to which degree, if any, an LLM was used in creating this pull request.
LLM used for the following
...