[PR #1179] [MERGED] Address profile import asset transaction race #4962

Closed
opened 2026-10-22 04:12:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1179
Author: @cha1latte
Created: 5/24/2026
Status: ✅ Merged
Merged: 5/24/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/pr-1153-atomic-profile-assets


📝 Commits (3)

  • 780003f Make profile imports atomic with rollback
  • 1929b5e Address profile import asset transaction race
  • ca84056 Merge refactor into profile asset transaction fix

📊 Changes

5 files changed (+791 additions, -55 deletions)

View changed files

📝 src-tauri/crates/storage/src/lib.rs (+312 -0)
📝 src-tauri/src/commands/storage/profile.rs (+69 -6)
📝 src-tauri/src/commands/storage/profile/assets.rs (+370 -36)
📝 src-tauri/src/commands/storage/profile/legacy.rs (+21 -8)
📝 src-tauri/src/commands/storage/profile/zip_import.rs (+19 -5)

📄 Description

What?

This stacks on #1153 and addresses the remaining CodeRabbit blocker before merge. It keeps profile assets staged until the collection replacement transaction reaches its install phase, then publishes the assets through a storage transaction hook.

Why?

#1153 made profile imports rollback-capable, but imported asset directories were still published before replace_all_many committed the collection batch. That left a window where a concurrent import or asset read could observe mixed profile state.

How?

  • Added FileStorage::replace_all_many_and_then so profile import can run asset publishing while the collection transaction is still guarded by the storage lock.
  • Changed profile asset restore helpers to stage assets first and publish them later via RestoredProfileAssets::install.
  • Kept rollback behavior for collection replacement, staged assets, and installed assets.
  • Added regression coverage for storage hook rollback, staged asset visibility, and profile import collection rollback when asset install fails.

Testing?

  • cargo check --manifest-path src-tauri\Cargo.toml
  • cargo test --manifest-path src-tauri\Cargo.toml -p marinara-storage replace_all_many -- --nocapture
  • cargo test --manifest-path src-tauri\Cargo.toml -p marinara-engine profile_asset -- --nocapture
  • cargo test --manifest-path src-tauri\Cargo.toml -p marinara-engine profile_import_rolls_back_collections_when_asset_install_fails -- --nocapture

Screenshots

N/A; Rust storage/profile import behavior only.

Anything Else?

This is intended as the mergeable replacement/follow-up path for #1153 because the #1153 head branch lives in Pasta-Devs, and this workflow does not push directly to upstream.


🔄 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/Pasta-Devs/Marinara-Engine/pull/1179 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/24/2026 **Status:** ✅ Merged **Merged:** 5/24/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/pr-1153-atomic-profile-assets` --- ### 📝 Commits (3) - [`780003f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/780003f58834ac6a006d5427f5bf9c53ad8585da) Make profile imports atomic with rollback - [`1929b5e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1929b5e68961de0dab4c64624412b4354fa68eb1) Address profile import asset transaction race - [`ca84056`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ca84056ca0f99fed06eea416cd919014cb4b1948) Merge refactor into profile asset transaction fix ### 📊 Changes **5 files changed** (+791 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/crates/storage/src/lib.rs` (+312 -0) 📝 `src-tauri/src/commands/storage/profile.rs` (+69 -6) 📝 `src-tauri/src/commands/storage/profile/assets.rs` (+370 -36) 📝 `src-tauri/src/commands/storage/profile/legacy.rs` (+21 -8) 📝 `src-tauri/src/commands/storage/profile/zip_import.rs` (+19 -5) </details> ### 📄 Description ## What? This stacks on #1153 and addresses the remaining CodeRabbit blocker before merge. It keeps profile assets staged until the collection replacement transaction reaches its install phase, then publishes the assets through a storage transaction hook. ## Why? #1153 made profile imports rollback-capable, but imported asset directories were still published before `replace_all_many` committed the collection batch. That left a window where a concurrent import or asset read could observe mixed profile state. ## How? - Added `FileStorage::replace_all_many_and_then` so profile import can run asset publishing while the collection transaction is still guarded by the storage lock. - Changed profile asset restore helpers to stage assets first and publish them later via `RestoredProfileAssets::install`. - Kept rollback behavior for collection replacement, staged assets, and installed assets. - Added regression coverage for storage hook rollback, staged asset visibility, and profile import collection rollback when asset install fails. ## Testing? - `cargo check --manifest-path src-tauri\Cargo.toml` - `cargo test --manifest-path src-tauri\Cargo.toml -p marinara-storage replace_all_many -- --nocapture` - `cargo test --manifest-path src-tauri\Cargo.toml -p marinara-engine profile_asset -- --nocapture` - `cargo test --manifest-path src-tauri\Cargo.toml -p marinara-engine profile_import_rolls_back_collections_when_asset_install_fails -- --nocapture` ## Screenshots N/A; Rust storage/profile import behavior only. ## Anything Else? This is intended as the mergeable replacement/follow-up path for #1153 because the #1153 head branch lives in `Pasta-Devs`, and this workflow does not push directly to upstream. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12:03 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4962
No description provided.