Skip to content

Commit 461d1ac

Browse files
authored
Merge pull request #91 from kinode-dao/develop
develop v0.9.1
2 parents 284f202 + 1c495ad commit 461d1ac

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "kinode_process_lib"
33
description = "A library for writing Kinode processes in Rust."
4-
version = "0.9.0"
4+
version = "0.9.1"
55
edition = "2021"
66
license-file = "LICENSE"
77
homepage = "https://kinode.org"

src/vfs/directory.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{parse_response, vfs_request, DirEntry, VfsAction, VfsError, VfsResponse};
1+
use super::{parse_response, vfs_request, DirEntry, FileType, VfsAction, VfsError, VfsResponse};
22

33
/// Vfs helper struct for a directory.
44
/// Opening or creating a directory will give you a Result<Directory>.
@@ -36,13 +36,38 @@ impl Directory {
3636
pub fn open_dir(path: &str, create: bool, timeout: Option<u64>) -> Result<Directory, VfsError> {
3737
let timeout = timeout.unwrap_or(5);
3838
if !create {
39+
let message = vfs_request(path, VfsAction::Metadata)
40+
.send_and_await_response(timeout)
41+
.unwrap()
42+
.map_err(|e| VfsError::IOError {
43+
error: e.to_string(),
44+
path: path.to_string(),
45+
})?;
46+
match parse_response(message.body())? {
47+
VfsResponse::Metadata(m) => {
48+
if m.file_type != FileType::Directory {
49+
return Err(VfsError::IOError {
50+
error: "Entry at path not a directory".to_string(),
51+
path: path.to_string(),
52+
});
53+
}
54+
}
55+
VfsResponse::Err(e) => return Err(e),
56+
_ => {
57+
return Err(VfsError::ParseError {
58+
error: "unexpected response".to_string(),
59+
path: path.to_string(),
60+
})
61+
}
62+
}
63+
3964
return Ok(Directory {
4065
path: path.to_string(),
4166
timeout,
4267
});
4368
}
4469

45-
let message = vfs_request(path, VfsAction::CreateDir)
70+
let message = vfs_request(path, VfsAction::CreateDirAll)
4671
.send_and_await_response(timeout)
4772
.unwrap()
4873
.map_err(|e| VfsError::IOError {

0 commit comments

Comments
 (0)