This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
feat(rome_fs): implement permission checking in the memory filesystem #3882
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 PR adds permission checks to the
MemoryFileSystem
, so that it's no longer possible to callread_to_string
on a file that was not open with theread
option orset_content
on file open with thewrite
option.I've also used the opportunity to further implement the specific behavior of the
create_new
andtruncate
flags to make sure they work the same way in bothFileSystem
implementations, and remove theappend
flag since our FileSystem API doesn't support appending content to a file anyway.Finally I've removed the specialized implementations of the
FileSystemExt
trait in favor of a single generic implementation over any type implementing the base trait (this is the convention for Rust extension trait as it makes it possible to use those extension methods on&dyn FileSystem
objects for instance), and adjusted the set of methods exposed by the extension trait (and the open options they use) to align them with the creation methods exposed bystd::fs::File
to make the API more accessible to contributors familiar with the Rust standard library.Test Plan
I've added additional tests for the memory filesystem to ensure the newly introduced checks work as expected