[PR #4015] [MERGED] feat(server): trash asset #10207

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

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/4015
Author: @shenlong-tanwen
Created: 9/7/2023
Status: Merged
Merged: 10/6/2023
Merged by: @alextran1502

Base: mainHead: refactor/server-delete-assets


📝 Commits (10+)

📊 Changes

117 files changed (+3154 additions, -927 deletions)

View changed files

📝 cli/src/api/open-api/api.ts (+354 -83)
📝 mobile/assets/i18n/en-US.json (+13 -1)
📝 mobile/ios/Podfile.lock (+1 -1)
📝 mobile/lib/modules/archive/providers/archive_asset_provider.dart (+1 -0)
📝 mobile/lib/modules/asset_viewer/views/gallery_viewer.dart (+48 -16)
📝 mobile/lib/modules/backup/views/backup_controller_page.dart (+3 -1)
📝 mobile/lib/modules/favorite/providers/favorite_provider.dart (+1 -0)
📝 mobile/lib/modules/home/ui/control_bottom_app_bar.dart (+17 -8)
📝 mobile/lib/modules/home/ui/profile_drawer/profile_drawer.dart (+28 -0)
📝 mobile/lib/modules/home/views/home_page.dart (+17 -1)
mobile/lib/modules/trash/providers/trashed_asset.provider.dart (+144 -0)
mobile/lib/modules/trash/services/trash.service.dart (+48 -0)
mobile/lib/modules/trash/views/trash_page.dart (+276 -0)
📝 mobile/lib/routing/router.dart (+2 -0)
📝 mobile/lib/routing/router.gr.dart (+26 -0)
📝 mobile/lib/shared/models/asset.dart (+19 -6)
📝 mobile/lib/shared/models/asset.g.dart (+81 -26)
📝 mobile/lib/shared/providers/asset.provider.dart (+32 -10)
📝 mobile/lib/shared/providers/server_info.provider.dart (+2 -0)
📝 mobile/lib/shared/providers/websocket.provider.dart (+7 -0)

...and 80 more files

📄 Description

Fixes: #739.
Fixes #937.
Fixes #2840.

Changes made:

  • Made it possible to soft delete ( Trash ) assets by default instead of permanently deleting them. The trashed assets are accessible only in the Trash page and will not show up anywhere else.
  • Restore / Permanently remove assets from the trash

https://github.com/immich-app/immich/assets/139912620/9655e973-d831-4a9e-907a-1712fa339021

  • Admin setting to disable trash if not needed and an option to set the duration (in days) to keep the asset in trash. If the assets are not restored before the configured date, they will be permanently removed from Immich
image
  • Mobile app implementation for the trash view
Side bar Trash page Selection
Side-bar Mobile-Trash Mobile-Trash-1
  • If trash is enabled and an asset is removed from the web, it will not be re-uploaded by the mobile app as long as the asset is still in trash. However, if the asset is removed from the trash, it will still be uploaded from the mobile app in the next backup sync. (This can be addressed by displaying an alert to the user asking them to remove the local asset as well. But that has to be handled as a separate PR independent of this one)
  • Changes made in #4045 are cherry picked since trash enabled / disabled handling required server config / features in mobile app
  • DELETE /asset/ moved to domain in server

Warning

Deleting local assets still deletes them permanently from the mobile app. The following two features has to be added, possibly in future PRs:

  • An option in mobile app to delete local only asset / both local and remote asset during deletion
  • An option to trash local assets as well (Probably by moving the file to Immich app's internal directory)

How was this tested:

  • Trash an asset and ensure that is it not permanently deleted and accessible from trash
  • Trash an asset with trash disabled and ensure that it gets permanently removed
  • Restore an asset from trash and ensure that it gets displayed in all pages
  • Ensure that the asset is not returned in search results, faces, albums, favorites, etc. once trashed
  • Ensure that the asset gets returned in search, etc., once restored
  • Ensure audit logs are working when the asset is permanently removed from Immich
  • Ensured duplicate uploads still detect assets from trash
  • Ensured that the trash page is not accessible in Mobile / Web once trash is disabled

Todo

  • verify search still works
  • verify face matching ignores deleted faces
  • verify audit table still works
  • mobile implementation
  • empty trash bin button on the web
  • system config for trash can feature flag
  • system config for trash can duration (auto delete after x days)
  • cron job uses system config for processing trashed assets
  • show confirm when clicking delete action of trash is disabled.
  • hide trash can in side menu if trash is disabled

🔄 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/4015 **Author:** [@shenlong-tanwen](https://github.com/shenlong-tanwen) **Created:** 9/7/2023 **Status:** ✅ Merged **Merged:** 10/6/2023 **Merged by:** [@alextran1502](https://github.com/alextran1502) **Base:** `main` ← **Head:** `refactor/server-delete-assets` --- ### 📝 Commits (10+) - [`ce93f03`](https://github.com/immich-app/immich/commit/ce93f0353dbc27e1ae53bc138f3b760b1b578e16) refactor(server): delete assets endpoint - [`03699fb`](https://github.com/immich-app/immich/commit/03699fbaf2bf6475bd258b09f8bc95cb5b20eae2) fix: formatting - [`e80461e`](https://github.com/immich-app/immich/commit/e80461e4097bbb033c48552842b18e1a545db623) chore: cleanup - [`89396d5`](https://github.com/immich-app/immich/commit/89396d5ab58ff88cf79246cb2bacf8a6e60af2c8) chore: open api - [`ccf6ff9`](https://github.com/immich-app/immich/commit/ccf6ff9db38e2b5330f20974a85fbb55d8681f4b) chore(mobile): replace DeleteAssetDTO with BulkIdsDTOs - [`0971e8a`](https://github.com/immich-app/immich/commit/0971e8a137448c9973fe81a6004578eed6c93f98) feat: trash an asset - [`27a6b9a`](https://github.com/immich-app/immich/commit/27a6b9a758148e21c5c62d04281c9489beaeeac1) chore(server): formatting - [`2beac4f`](https://github.com/immich-app/immich/commit/2beac4f3ee681fc470b49755aac1390be5636c8c) chore: open api - [`f2542c2`](https://github.com/immich-app/immich/commit/f2542c2937fd38bcfbf1c260474455db61bee807) chore: wording - [`a028c29`](https://github.com/immich-app/immich/commit/a028c29abd93654fa911748ed04babe1ed978c01) chore: open-api ### 📊 Changes **117 files changed** (+3154 additions, -927 deletions) <details> <summary>View changed files</summary> 📝 `cli/src/api/open-api/api.ts` (+354 -83) 📝 `mobile/assets/i18n/en-US.json` (+13 -1) 📝 `mobile/ios/Podfile.lock` (+1 -1) 📝 `mobile/lib/modules/archive/providers/archive_asset_provider.dart` (+1 -0) 📝 `mobile/lib/modules/asset_viewer/views/gallery_viewer.dart` (+48 -16) 📝 `mobile/lib/modules/backup/views/backup_controller_page.dart` (+3 -1) 📝 `mobile/lib/modules/favorite/providers/favorite_provider.dart` (+1 -0) 📝 `mobile/lib/modules/home/ui/control_bottom_app_bar.dart` (+17 -8) 📝 `mobile/lib/modules/home/ui/profile_drawer/profile_drawer.dart` (+28 -0) 📝 `mobile/lib/modules/home/views/home_page.dart` (+17 -1) ➕ `mobile/lib/modules/trash/providers/trashed_asset.provider.dart` (+144 -0) ➕ `mobile/lib/modules/trash/services/trash.service.dart` (+48 -0) ➕ `mobile/lib/modules/trash/views/trash_page.dart` (+276 -0) 📝 `mobile/lib/routing/router.dart` (+2 -0) 📝 `mobile/lib/routing/router.gr.dart` (+26 -0) 📝 `mobile/lib/shared/models/asset.dart` (+19 -6) 📝 `mobile/lib/shared/models/asset.g.dart` (+81 -26) 📝 `mobile/lib/shared/providers/asset.provider.dart` (+32 -10) 📝 `mobile/lib/shared/providers/server_info.provider.dart` (+2 -0) 📝 `mobile/lib/shared/providers/websocket.provider.dart` (+7 -0) _...and 80 more files_ </details> ### 📄 Description Fixes: #739. Fixes #937. Fixes #2840. #### Changes made: - Made it possible to soft delete ( Trash ) assets by default instead of permanently deleting them. The trashed assets are accessible only in the Trash page and will not show up anywhere else. - Restore / Permanently remove assets from the trash https://github.com/immich-app/immich/assets/139912620/9655e973-d831-4a9e-907a-1712fa339021 - Admin setting to disable trash if not needed and an option to set the duration (in days) to keep the asset in trash. If the assets are not restored before the configured date, they will be permanently removed from Immich <img width="1204" alt="image" src="https://github.com/immich-app/immich/assets/139912620/63f6d28d-2d6e-40be-a452-8f2ec654662f"> - Mobile app implementation for the trash view Side bar | Trash page | Selection :-: | :-: | :-: | ![Side-bar](https://github.com/immich-app/immich/assets/139912620/65909881-3a96-4abe-912d-615e54438604)|![Mobile-Trash](https://github.com/immich-app/immich/assets/139912620/a8283587-2e59-4a8c-8468-27640c985c80)|![Mobile-Trash-1](https://github.com/immich-app/immich/assets/139912620/c4bd10c5-3817-4e1b-93be-cc9af90ceef9) - If trash is enabled and an asset is removed from the web, it will not be re-uploaded by the mobile app as long as the asset is still in trash. However, if the asset is removed from the trash, it will still be uploaded from the mobile app in the next backup sync. (This can be addressed by displaying an alert to the user asking them to remove the local asset as well. But that has to be handled as a separate PR independent of this one) - Changes made in #4045 are cherry picked since trash enabled / disabled handling required server config / features in mobile app - `DELETE /asset/` moved to domain in server > [!WARNING] >Deleting local assets still deletes them permanently from the mobile app. The following two features has to be added, possibly in future PRs: > - An option in mobile app to delete local only asset / both local and remote asset during deletion > - An option to trash local assets as well (Probably by moving the file to Immich app's internal directory) #### How was this tested: - Trash an asset and ensure that is it not permanently deleted and accessible from trash - Trash an asset with trash disabled and ensure that it gets permanently removed - Restore an asset from trash and ensure that it gets displayed in all pages - Ensure that the asset is not returned in search results, faces, albums, favorites, etc. once trashed - Ensure that the asset gets returned in search, etc., once restored - Ensure audit logs are working when the asset is permanently removed from Immich - Ensured duplicate uploads still detect assets from trash - Ensured that the trash page is not accessible in Mobile / Web once trash is disabled #### Todo - [x] verify search still works - [x] verify face matching ignores deleted faces - [x] verify audit table still works - [x] mobile implementation - [x] empty trash bin button on the web - [x] system config for trash can feature flag - [x] system config for trash can duration (auto delete after x days) - [x] cron job uses system config for processing trashed assets - [x] show confirm when clicking delete action of trash is disabled. - [x] hide trash can in side menu if trash is disabled --- <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:17:45 +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#10207