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

Additional "directory" property #184

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 0.7.0

- breaking change. Add a `directory` property into a directory block. PR [#184](https://github.com/datablockset/blockset/pull/184).

## 0.6.0

- license changed to AGPL 3.0. PR [#177](https://github.com/datablockset/blockset/pull/177).
Expand Down
6 changes: 3 additions & 3 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.6.0"
version = "0.7.0"
edition = "2021"
license = "AGPL-3.0-or-later"
authors = ["Sergey Shandar"]
repository = "https://github.com/datablockset/blockset"

[workspace.dependencies]
blockset-lib = { path = "blockset-lib", version = "0.6.0" }
blockset-lib = { path = "blockset-lib", version = "0.7.0" }
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.5"
nanvm-lib = "0.1.0"
10 changes: 9 additions & 1 deletion blockset-lib/src/app/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ fn property<M: Manager>(
)
}

pub fn directory_js<M: Manager>(m: M) -> JsStringRef<M::Dealloc> {
let directory16 = "directory".encode_utf16().collect::<Vec<_>>();
new_string(m, directory16).to_ref()
}

fn dir_to_json<M: Manager>(
m: M,
list: impl ExactSizeIterator<Item = Property<M::Dealloc>>,
) -> io::Result<String> {
to_json(m.new_js_object(list)).map_err(|_| invalid_input("to_json"))
let dir = m.new_js_object(list);
let property = (directory_js(m), dir);
let block = m.new_js_object([property]);
to_json(block).map_err(|_| invalid_input("to_json"))
}

fn calculate_len(files: &[(String, u64)], state: &mut State) {
Expand Down
14 changes: 12 additions & 2 deletions blockset-lib/src/app/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use crate::{
uint::u224::U224,
};

use super::{add::posix_path, get_hash, invalid_input, js_string_to_string, str_to_hash, try_move};
use super::{
add::{directory_js, posix_path},
get_hash, invalid_input, js_string_to_string, str_to_hash, try_move,
};

pub fn restore(
io: &impl Io,
Expand Down Expand Up @@ -73,7 +76,14 @@ fn get_if(d: &U224, path: &str, io: &impl Io) -> io::Result<()> {
let mut w = Cursor::new(&mut buffer);
restore(io, d, &mut w, &mut |_, _| Ok(()))?;
let json = try_move::<_, JsObjectRef<_>>(parse_json(io, GLOBAL, buffer)?)?;
let items = json.items();
let dir = directory_js(GLOBAL);
let dir_json = json
.items()
.iter()
.find(|p| p.0.items() == dir.items())
.ok_or(invalid_input("directory"))?;
let dir_obj = try_move::<_, JsObjectRef<_>>(dir_json.1.clone())?;
let items = dir_obj.items();
let t = items.len();
let mut b = 0;
for (offset, (k, v)) in items.iter().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion issues/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Issues

- Restore code coverage. We may switch to `cargo-llvm-cov` from `tarpauilin`.
- Change directory structure.
- ASN.1
- remove `--to-posix-eol` and replace it with a separate utility
Loading