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

fs, File and Path API #264

Open
wants to merge 18 commits into
base: Abstract_file_access_layer_111
Choose a base branch
from

Conversation

someotherself
Copy link
Collaborator

@someotherself someotherself commented Dec 15, 2024

Issue #97

Implementation for:

crypto::fs_api::async::fs::OpenOptions
crypto::fs_api::async::fs::File (partial)
crypto::fs_api::async::fs (partial)
crypto::fs_api::path::Path.
crypto::fs_api::path::PathBuf.

Still on the to do list:

  • Check if crypto::fs_api::path::Path needs to be used as import in crypto::fs_api::async::fs
  • Implement the rest of the functions in crypto::fs_api::async::fs
  • Fix parsing of path components so they don't leak (they use OsStr so far). May need our own Component struct and enum
  • Implement crypto::fs_api::async::io if needed

@someotherself someotherself changed the title Abstract file access layer 111 fs, File and Path API Dec 15, 2024
@radumarias radumarias linked an issue Dec 15, 2024 that may be closed by this pull request
async_util::call_async(crate::crypto::fs_api::r#async::fs::metadata(self))
}

pub fn symlink_metadata(&self) -> Result<Metadata> {
Copy link
Member

Choose a reason for hiding this comment

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

add rustdoc to indicate it's not implemented

Ok(stack.iter().collect::<PathBuf>())
}

pub fn read_link(&self) -> Result<PathBuf> {
Copy link
Member

Choose a reason for hiding this comment

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

We don't yet have links implemented and we need to ask links from EncryptedFs, not local path like std Path does, so make this unimplemented and add rustdoc too

Ok(PathBuf::from(path.read_link()))
}

pub fn read_dir(&self) -> Result<ReadDir> {
Copy link
Member

Choose a reason for hiding this comment

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

You need to interrogate EncryptedFs, not std Path :) we have that method in there

#[cfg(test)]
mod test;

/// Wrapper around [`std::path::Path`] to allow use on EncryptedFs.
Copy link
Member

Choose a reason for hiding this comment

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

Is this accurate? as we don't use std Path internally, maybe use similar term?

@@ -57,7 +53,7 @@ async fn init_fs() -> anyhow::Result<()> {
Ok(())
}

fn _add_create<'a>(opts: &'a mut OpenOptions, path: &Path) -> &'a mut OpenOptions {
fn _add_create<'a>(opts: &'a mut OpenOptions, path: &std::path::Path) -> &'a mut OpenOptions {
if !path.to_path_buf().exists() {
Copy link
Member

Choose a reason for hiding this comment

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

I think here we need to use crypto::fs_api::path::Path

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.

[async] fs, File and io API
2 participants