Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request refactors the scope management and file handling logic in the
rspack_storage
crate. The changes aim to simplify the code, improve efficiency, and ensure better error handling. The key changes include modifying the scope writing strategy, adding new utility functions, and updating test cases accordingly.Scope Management and File Handling Improvements:
crates/rspack_storage/src/pack/manager/mod.rs
: Refactored thesave_scopes
function to streamline the process by merging thebefore_all
andafter_all
steps and introducing themerge_changed
method. [1] [2]crates/rspack_storage/src/pack/strategy/mod.rs
: Updated theScopeWriteStrategy
trait to use the newmerge_changed
method and modified thebefore_all
andafter_all
methods to handle multiple scopes. [1] [2]New Utility Functions:
crates/rspack_storage/src/pack/strategy/split/handle_file.rs
: Added functionsprepare_scope
,prepare_scope_dirs
,write_lock
,remove_lock
, and refactoredmove_files
andrecovery_move_lock
to improve file handling. [1] [2] [3] [4] [5]Test Case Updates:
crates/rspack_storage/src/pack/strategy/split/util.rs
: Introduced theflag_scope_wrote
function to update the scope's metadata and modified test utilities to use the new scope preparation and merging logic. [1] [2] [3]crates/rspack_storage/src/pack/strategy/split/validate_scope.rs
: Updated tests to incorporate the new scope preparation and merging methods, ensuring they align with the refactored logic. [1] [2] [3]Miscellaneous Changes:
crates/rspack_storage/src/pack/strategy/split/write_scope.rs
: Adjusted theSplitPackStrategy
implementation to use the new utility functions for file operations and scope management. [1] [2]crates/rspack_storage/tests/build.rs
: Renamed a test function for clarity.Checklist