[PR #2453] [MERGED] [PM-1646] Add thread safety to migration process #3572

Closed
opened 2025-11-26 23:34:34 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/2453
Author: @mpbw2
Created: 3/28/2023
Status: Merged
Merged: 3/28/2023
Merged by: @mpbw2

Base: masterHead: bugfix/migration-thread-safety


📝 Commits (2)

📊 Changes

3 files changed (+25 additions, -9 deletions)

View changed files

📝 src/Core/Abstractions/IStateMigrationService.cs (+1 -2)
📝 src/Core/Services/StateMigrationService.cs (+22 -2)
📝 src/Core/Services/StateService.cs (+2 -5)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

This makes the storage migration process thread safe to cover for cases where migration is inadvertently called more than once during app initialization.

Code changes

  • StateMigrationService.cs: Combine checking for and performing migration into a single step behind a SemaphoreSlim to make sure migration will complete before executing a subsequent check.
  • StateService.cs: Replace NeedsMigration() and Migrate() with MigrateIfNeeded()

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team

🔄 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/bitwarden/android/pull/2453 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 3/28/2023 **Status:** ✅ Merged **Merged:** 3/28/2023 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `master` ← **Head:** `bugfix/migration-thread-safety` --- ### 📝 Commits (2) - [`9c45458`](https://github.com/bitwarden/android/commit/9c45458e30fa2c9d61baf5142deeddb8680127ab) Make migration process thread safe - [`b0749cb`](https://github.com/bitwarden/android/commit/b0749cb076b738081812e5ffe2cbde7cad2abc70) tweaks ### 📊 Changes **3 files changed** (+25 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/Core/Abstractions/IStateMigrationService.cs` (+1 -2) 📝 `src/Core/Services/StateMigrationService.cs` (+22 -2) 📝 `src/Core/Services/StateService.cs` (+2 -5) </details> ### 📄 Description ## Type of change - [X] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> This makes the storage migration process thread safe to cover for cases where migration is inadvertently called more than once during app initialization. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **StateMigrationService.cs:** Combine checking for and performing migration into a single step behind a `SemaphoreSlim` to make sure migration will complete before executing a subsequent check. * **StateService.cs:** Replace `NeedsMigration()` and `Migrate()` with `MigrateIfNeeded()` ## Before you submit - Please check for formatting errors (`dotnet format --verify-no-changes`) (required) - Please add **unit tests** where it makes sense to do so (encouraged but not required) - If this change requires a **documentation update** - notify the documentation team - If this change has particular **deployment requirements** - notify the DevOps team --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:34:34 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3572