Skip to content

Commit

Permalink
add_entry
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Mar 12, 2024
1 parent f0c9891 commit 9e56926
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
7 changes: 5 additions & 2 deletions blockset-lib/src/app/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use nanvm_lib::{
serializer::to_json,
};

use crate::{cdt::tree_add::TreeAdd, common::{print::Print, status_line::StatusLine}};
use crate::{
cdt::tree_add::TreeAdd,
common::{print::Print, status_line::StatusLine},
};

use super::{invalid_input, read_to_tree, read_to_tree_file};

Expand Down Expand Up @@ -74,7 +77,7 @@ impl<'a, T: Io, S: 'a + TreeAdd, F: Fn(&'a T) -> S> Add<'a, T, S, F> {
self.display_new,
)
}
fn path_to_json(&self, state: &mut StatusLine<'a, T>, path: &str) -> io::Result<String> {
fn path_to_json(&self, state: &mut StatusLine<'a, T>, path: &str) -> io::Result<String> {
let files = read_dir_recursive(self.io, path)?;
let mut list = Vec::default();
for e in files {
Expand Down
17 changes: 10 additions & 7 deletions blockset-lib/src/app/add_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use std::io;

use io_trait::{Io, Metadata};

use crate::{cdt::tree_add::TreeAdd, common::{print::Print, status_line::StatusLine}};
use crate::{
cdt::tree_add::TreeAdd,
common::{print::Print, status_line::StatusLine},
};

use super::{add::Add, invalid_input, is_to_posix_eol};

Expand All @@ -14,13 +17,13 @@ pub fn add_entry<'a, T: Io, S: 'a + TreeAdd>(
) -> io::Result<()> {
let path = a.next().ok_or(invalid_input("missing file name"))?;
let to_posix_eol = is_to_posix_eol(a)?;
let add = Add {
io,
storage,
to_posix_eol,
display_new,
};
let k = {
let add = Add {
io,
storage,
to_posix_eol,
display_new,
};
let mut state = StatusLine::new(io);
if io.metadata(&path)?.is_dir() {
add.add_dir(&mut state, &path)?
Expand Down

0 comments on commit 9e56926

Please sign in to comment.