Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(secure_storage): process file system operations one at a time on Windows #5195

Merged
merged 6 commits into from
Jul 29, 2024

Conversation

Jordan-Nelson
Copy link
Member

@Jordan-Nelson Jordan-Nelson commented Jul 23, 2024

Issue #, if available: #5190

Description of changes:

  • Update FileKeyValueStore to process tasks one at a time in the order in which they are received to prevent multiple parallel file operations from corrupting the file
  • Update readAll to log an error and clear the file contents if it is corrupted as it will be unreadable and unrecoverable
  • Annotate readAll/writeAll as visible for testing
  • add tests for in-memory fs and local fs

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Jordan-Nelson Jordan-Nelson marked this pull request as ready for review July 23, 2024 19:58
@Jordan-Nelson Jordan-Nelson requested a review from a team as a code owner July 23, 2024 19:58
@Jordan-Nelson Jordan-Nelson changed the title fix(secure_storage): process fs events in the order they are received fix(secure_storage): process file system events in the order they are received Jul 23, 2024
@Jordan-Nelson Jordan-Nelson changed the title fix(secure_storage): process file system events in the order they are received fix(secure_storage): process file system operations in the order they are received Jul 23, 2024
@Jordan-Nelson Jordan-Nelson changed the title fix(secure_storage): process file system operations in the order they are received fix(secure_storage): process file system operations one at a time Jul 23, 2024
@Jordan-Nelson Jordan-Nelson changed the title fix(secure_storage): process file system operations one at a time fix(secure_storage): process file system operations one at a time on Windows Jul 23, 2024
final data = await readAll();
data[key] = value;
return writeAll(data);
});
}

/// Overwrites the existing data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should writeAll be wrapped by the scheduler as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline - I updated writeAll and readAll to be annotated with @visibleForTesting as these apis are really private and only exposed for testing.

@Jordan-Nelson Jordan-Nelson merged commit 26b970f into main Jul 29, 2024
123 checks passed
@Jordan-Nelson Jordan-Nelson deleted the fix/secure_storage/process-events branch July 29, 2024 15:49
tyllark pushed a commit to tyllark/amplify-flutter that referenced this pull request Aug 14, 2024
…Windows (aws-amplify#5195)

* fix(secure_storage): process fs events in the order they are received

* chore: clear file when it is corrupted

* chore: add test for stale data during parallel writes

* chore: add visibleForTesting annotations

* chore: add tests for in-memory fs and local fs

* chore: remove print from test
tyllark pushed a commit that referenced this pull request Aug 20, 2024
…Windows (#5195)

* fix(secure_storage): process fs events in the order they are received

* chore: clear file when it is corrupted

* chore: add test for stale data during parallel writes

* chore: add visibleForTesting annotations

* chore: add tests for in-memory fs and local fs

* chore: remove print from test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants