Skip to content

Commit

Permalink
Merge pull request #91 from kinode-dao/develop
Browse files Browse the repository at this point in the history
develop v0.9.1
  • Loading branch information
nick1udwig authored Sep 2, 2024
2 parents 284f202 + 1c495ad commit 461d1ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode_process_lib"
description = "A library for writing Kinode processes in Rust."
version = "0.9.0"
version = "0.9.1"
edition = "2021"
license-file = "LICENSE"
homepage = "https://kinode.org"
Expand Down
29 changes: 27 additions & 2 deletions src/vfs/directory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{parse_response, vfs_request, DirEntry, VfsAction, VfsError, VfsResponse};
use super::{parse_response, vfs_request, DirEntry, FileType, VfsAction, VfsError, VfsResponse};

/// Vfs helper struct for a directory.
/// Opening or creating a directory will give you a Result<Directory>.
Expand Down Expand Up @@ -36,13 +36,38 @@ impl Directory {
pub fn open_dir(path: &str, create: bool, timeout: Option<u64>) -> Result<Directory, VfsError> {
let timeout = timeout.unwrap_or(5);
if !create {
let message = vfs_request(path, VfsAction::Metadata)
.send_and_await_response(timeout)
.unwrap()
.map_err(|e| VfsError::IOError {
error: e.to_string(),
path: path.to_string(),
})?;
match parse_response(message.body())? {
VfsResponse::Metadata(m) => {
if m.file_type != FileType::Directory {
return Err(VfsError::IOError {
error: "Entry at path not a directory".to_string(),
path: path.to_string(),
});
}
}
VfsResponse::Err(e) => return Err(e),
_ => {
return Err(VfsError::ParseError {
error: "unexpected response".to_string(),
path: path.to_string(),
})
}
}

return Ok(Directory {
path: path.to_string(),
timeout,
});
}

let message = vfs_request(path, VfsAction::CreateDir)
let message = vfs_request(path, VfsAction::CreateDirAll)
.send_and_await_response(timeout)
.unwrap()
.map_err(|e| VfsError::IOError {
Expand Down

0 comments on commit 461d1ac

Please sign in to comment.