Skip to content
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

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Nov 28, 2022

Summary

This PR adds permission checks to the MemoryFileSystem, so that it's no longer possible to call read_to_string on a file that was not open with the read option or set_content on file open with the write option.

I've also used the opportunity to further implement the specific behavior of the create_new and truncate flags to make sure they work the same way in both FileSystem implementations, and remove the append 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 by std::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

@netlify
Copy link

netlify bot commented Nov 28, 2022

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 4d23e9a
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63848de280ad67000846280c

@leops leops merged commit 145c38b into main Nov 28, 2022
@leops leops deleted the feature/memory-read-only branch November 28, 2022 14:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants