[PR #4112] [MERGED] chore(server): Store generated files (thumbnails, encoded video) in subdirectories #10252

Closed
opened 2026-02-05 14:18:31 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/4112
Author: @danieldietzler
Created: 9/16/2023
Status: Merged
Merged: 9/25/2023
Merged by: @jrasm91

Base: mainHead: fix/thumbnails-subdirectories


📝 Commits (10+)

  • e2620ca save thumbnails in subdirectories
  • c64606e migration job, migrate assets and face thumbnails
  • dc4ea35 fix tests
  • 4dbfdff directory depth of two instead of three
  • 35aa7e6 cleanup empty dirs after migration
  • ac39a01 clean up empty dirs after migration, migrate people without assetId
  • f24eed6 add job card for new migration job
  • 7d98711 fix removeEmptyDirs race condition because of missing await
  • ceca937 cleanup empty directories after asset deletion
  • ef617e7 move ensurePath to storage core

📊 Changes

36 files changed (+310 additions, -102 deletions)

View changed files

📝 cli/src/api/open-api/api.ts (+13 -0)
📝 mobile/openapi/doc/AllJobStatusResponseDto.md (+1 -0)
📝 mobile/openapi/doc/SystemConfigJobDto.md (+1 -0)
📝 mobile/openapi/lib/model/all_job_status_response_dto.dart (+9 -1)
📝 mobile/openapi/lib/model/job_name.dart (+3 -0)
📝 mobile/openapi/lib/model/system_config_job_dto.dart (+9 -1)
📝 mobile/openapi/test/all_job_status_response_dto_test.dart (+5 -0)
📝 mobile/openapi/test/system_config_job_dto_test.dart (+5 -0)
📝 server/immich-openapi-specs.json (+9 -0)
📝 server/src/domain/asset/asset.service.ts (+2 -1)
📝 server/src/domain/facial-recognition/facial-recognition.service.spec.ts (+5 -5)
📝 server/src/domain/facial-recognition/facial-recognition.services.ts (+18 -5)
📝 server/src/domain/job/job.constants.ts (+11 -0)
📝 server/src/domain/job/job.dto.ts (+3 -0)
📝 server/src/domain/job/job.repository.ts (+5 -0)
📝 server/src/domain/job/job.service.spec.ts (+3 -0)
📝 server/src/domain/job/job.service.ts (+3 -0)
📝 server/src/domain/media/media.service.spec.ts (+73 -62)
📝 server/src/domain/media/media.service.ts (+62 -12)
📝 server/src/domain/person/person.service.spec.ts (+2 -2)

...and 16 more files

📄 Description

This PR fixes #3314.

It helps improving the performance by storing generated files in subdirectories.
This yields smaller directory sizes (in terms of files per directory), decreasing the size of the inode entry.

  • Migration job to migrate all files to new folder structure (and possibly more migration stuff in the future)
  • Clean up directories if assets/people get deleted
  • New asset and face thumbnails will be stored at i.e. 89/ab/, if their id starts with 89abxxxx-xxxx...

There are already pretty good tests in place to check thumbnail creation (+ path), so I've not written further tests and updated those. Furthermore, I tried different edge cases like mix of old & new folder structure, does the migration sort them correctly, live photos (?), do empty folders get deleted if files get deleted and the (nested) folders would be empty afterwards?

The new migration job

Screenshot 2023-09-17 at 21 38 26

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/4112 **Author:** [@danieldietzler](https://github.com/danieldietzler) **Created:** 9/16/2023 **Status:** ✅ Merged **Merged:** 9/25/2023 **Merged by:** [@jrasm91](https://github.com/jrasm91) **Base:** `main` ← **Head:** `fix/thumbnails-subdirectories` --- ### 📝 Commits (10+) - [`e2620ca`](https://github.com/immich-app/immich/commit/e2620ca45444e34b37f72ebe9b749d2ccbce0ae2) save thumbnails in subdirectories - [`c64606e`](https://github.com/immich-app/immich/commit/c64606e749ba8dc9a8b081be22c4383a4e7c3bae) migration job, migrate assets and face thumbnails - [`dc4ea35`](https://github.com/immich-app/immich/commit/dc4ea35201b239833770fd7ef89e4672ab54107b) fix tests - [`4dbfdff`](https://github.com/immich-app/immich/commit/4dbfdff96dd68e1f6d5c2bfa99bbce01cf064007) directory depth of two instead of three - [`35aa7e6`](https://github.com/immich-app/immich/commit/35aa7e6a2e6829f7d6ec9da9356d1408388d4761) cleanup empty dirs after migration - [`ac39a01`](https://github.com/immich-app/immich/commit/ac39a011113ab003f7b906ca061257fe4f3e71ee) clean up empty dirs after migration, migrate people without assetId - [`f24eed6`](https://github.com/immich-app/immich/commit/f24eed698dd79c910b057f45cc3d920ffce796dc) add job card for new migration job - [`7d98711`](https://github.com/immich-app/immich/commit/7d9871174341b26a329789bca4fc6182da940fca) fix removeEmptyDirs race condition because of missing await - [`ceca937`](https://github.com/immich-app/immich/commit/ceca9374af8b56e65728d1de16f232d63dbb21a0) cleanup empty directories after asset deletion - [`ef617e7`](https://github.com/immich-app/immich/commit/ef617e798178ed9f33a8cbc8ad47dbff6a7fae1d) move ensurePath to storage core ### 📊 Changes **36 files changed** (+310 additions, -102 deletions) <details> <summary>View changed files</summary> 📝 `cli/src/api/open-api/api.ts` (+13 -0) 📝 `mobile/openapi/doc/AllJobStatusResponseDto.md` (+1 -0) 📝 `mobile/openapi/doc/SystemConfigJobDto.md` (+1 -0) 📝 `mobile/openapi/lib/model/all_job_status_response_dto.dart` (+9 -1) 📝 `mobile/openapi/lib/model/job_name.dart` (+3 -0) 📝 `mobile/openapi/lib/model/system_config_job_dto.dart` (+9 -1) 📝 `mobile/openapi/test/all_job_status_response_dto_test.dart` (+5 -0) 📝 `mobile/openapi/test/system_config_job_dto_test.dart` (+5 -0) 📝 `server/immich-openapi-specs.json` (+9 -0) 📝 `server/src/domain/asset/asset.service.ts` (+2 -1) 📝 `server/src/domain/facial-recognition/facial-recognition.service.spec.ts` (+5 -5) 📝 `server/src/domain/facial-recognition/facial-recognition.services.ts` (+18 -5) 📝 `server/src/domain/job/job.constants.ts` (+11 -0) 📝 `server/src/domain/job/job.dto.ts` (+3 -0) 📝 `server/src/domain/job/job.repository.ts` (+5 -0) 📝 `server/src/domain/job/job.service.spec.ts` (+3 -0) 📝 `server/src/domain/job/job.service.ts` (+3 -0) 📝 `server/src/domain/media/media.service.spec.ts` (+73 -62) 📝 `server/src/domain/media/media.service.ts` (+62 -12) 📝 `server/src/domain/person/person.service.spec.ts` (+2 -2) _...and 16 more files_ </details> ### 📄 Description This PR fixes #3314. It helps improving the performance by storing generated files in subdirectories. This yields smaller directory sizes (in terms of files per directory), decreasing the size of the inode entry. - Migration job to migrate all files to new folder structure (and possibly more migration stuff in the future) - Clean up directories if assets/people get deleted - New asset and face thumbnails will be stored at i.e. `89/ab/`, if their id starts with `89abxxxx-xxxx...` There are already pretty good tests in place to check thumbnail creation (+ path), so I've not written further tests and updated those. Furthermore, I tried different edge cases like mix of old & new folder structure, does the migration sort them correctly, live photos (?), do empty folders get deleted if files get deleted and the (nested) folders would be empty afterwards? ### The new migration job <img width="917" alt="Screenshot 2023-09-17 at 21 38 26" src="https://github.com/immich-app/immich/assets/36593685/a71777ed-1410-435e-9d62-b3e75d874330"> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:18:31 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#10252