Skip to content

Commit

Permalink
fix progress for add directory. (#172)
Browse files Browse the repository at this point in the history
* update nanvm

* fix fmt
  • Loading branch information
sergey-shandar committed May 8, 2024
1 parent 6c9ebcb commit 8f8f2fd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 0.5.2

- fix progress for `add`. PR [#172](https://github.com/datablockset/blockset/pull/172).

## 0.5.1

- Minor changes in documentation.

## 0.5.0

- `blockset get` can extract multiple files to a directory. PR [#169](https://github.com/datablockset/blockset/pull/169)
- `blockset get` can create directories recursively. PR [#168](https://github.com/datablockset/blockset/pull/168).
- `blockset get` can extract multiple files to a directory. PR [#169](https://github.com/datablockset/blockset/pull/169),
- `blockset get` can create directories recursively. PR [#168](https://github.com/datablockset/blockset/pull/168),
- `blockset add` works with directories. PR [#165](https://github.com/datablockset/blockset/pull/165).

## 0.4.2
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ members = ["blockset", "blockset-lib"]
resolver = "2"

[workspace.package]
version = "0.5.1"
version = "0.5.2"
edition = "2021"
license = "GPL-3.0-or-later"
authors = ["Sergey Shandar"]
repository = "https://github.com/datablockset/blockset"

[workspace.dependencies]
blockset-lib = { path = "blockset-lib", version = "0.5.1" }
io-trait = "0.10.0"
io-impl = "0.10.0"
io-test = "0.10.1"
blockset-lib = { path = "blockset-lib", version = "0.5.2" }
io-trait = "0.11.0"
io-impl = "0.11.0"
io-test = "0.11.0"
wasm-bindgen-test = "0.3.42"
nanvm-lib = "0.0.4"
nanvm-lib = "0.0.5"
5 changes: 4 additions & 1 deletion blockset-lib/src/app/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use nanvm_lib::{
new::New,
},
mem::{global::GLOBAL, manager::Manager},
serializer::to_json,
serializer::to_json::to_json,
};

use crate::{
Expand All @@ -26,6 +26,7 @@ pub struct Add<'a, T: Io, S: 'a + TreeAdd, F: Fn(&'a T) -> S> {
pub storage: &'a F,
pub to_posix_eol: bool,
pub display_new: bool,
pub new: u64,
pub status: StatusLine<'a, T>,
pub p: State,
}
Expand Down Expand Up @@ -103,6 +104,7 @@ impl<'a, T: Io, S: 'a + TreeAdd, F: Fn(&'a T) -> S> Add<'a, T, S, F> {
&mut self.status,
self.display_new,
self.p,
&mut self.new,
)
}
fn add_files(&mut self, path: &str, files: Vec<(String, u64)>) -> io::Result<String> {
Expand Down Expand Up @@ -136,6 +138,7 @@ impl<'a, T: Io, S: 'a + TreeAdd, F: Fn(&'a T) -> S> Add<'a, T, S, F> {
&mut self.status,
self.display_new,
self.p,
&mut self.new,
)
}
pub fn add_dir(&mut self, path: &str) -> io::Result<String> {
Expand Down
1 change: 1 addition & 0 deletions blockset-lib/src/app/add_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fn add_file_or_dir<'a, T: Io, S: 'a + TreeAdd>(
storage,
to_posix_eol,
display_new,
new: 0,
status: StatusLine::new(io),
p: State {
total: 0,
Expand Down
3 changes: 2 additions & 1 deletion blockset-lib/src/app/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::io::{self, Write};

use io_trait::Io;
use nanvm_lib::{
common::default::default,
js::any::Any,
mem::manager::Manager,
parser::{parse_with_tokens, Context, ParseError, ParseResult},
Expand All @@ -26,7 +27,7 @@ fn tokenize_and_parse<M: Manager>(
s: String,
) -> Result<ParseResult<M>, ParseError> {
parse_with_tokens(
&Context::new(manager, io, String::default()),
&mut Context::new(manager, io, default(), &mut default()),
tokenize(s).into_iter(),
)
}
Expand Down
9 changes: 5 additions & 4 deletions blockset-lib/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ fn read_to_tree<T: TreeAdd>(
state: &mut StatusLine<'_, impl Io>,
display_new: bool,
p: State,
new: &mut u64,
) -> io::Result<String> {
let mut tree = MainTreeAdd::new(s);
let mut new = 0;
while !read_to_tree_once(&mut file, state, display_new, p, &mut tree, &mut new)? {}
while !read_to_tree_once(&mut file, state, display_new, p, &mut tree, new)? {}
Ok(tree.end()?.0.to_base32())
}

Expand All @@ -120,11 +120,12 @@ fn read_to_tree_file(
state: &mut StatusLine<'_, impl Io>,
display_new: bool,
p: State,
new: &mut u64,
) -> io::Result<String> {
if to_posix_eol {
read_to_tree(s, ToPosixEol::new(f), state, display_new, p)
read_to_tree(s, ToPosixEol::new(f), state, display_new, p, new)
} else {
read_to_tree(s, f, state, display_new, p)
read_to_tree(s, f, state, display_new, p, new)
}
}

Expand Down

0 comments on commit 8f8f2fd

Please sign in to comment.