Skip to content

Commit

Permalink
seek
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Mar 11, 2024
1 parent a3f0e86 commit 8894ad3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions blockset-lib/src/app/add_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@ pub fn add_dir<'a, T: Io, S: 'a + TreeAdd, F: Fn(&'a T) -> S>(
path: &str,
) -> io::Result<()> {
let json = path_to_json(add, path)?;
// read_to_tree((add.storage)(add.io), Cursor::new(json), add.io, add.display_new)?;
add.io.stdout().println(["add-dir: ", json.as_str()])
}
10 changes: 5 additions & 5 deletions blockset-lib/src/common/progress.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io;
use std::io::{self, SeekFrom};

use io_trait::{File, Metadata};

Expand All @@ -13,9 +13,9 @@ pub trait Progress {

impl<T: File> Progress for T {
fn progress(&mut self) -> io::Result<State> {
Ok(State {
total: self.metadata()?.len(),
current: self.stream_position()?,
})
let current = self.stream_position()?;
let total = self.seek(SeekFrom::End(0))?;
self.seek(SeekFrom::Start(current))?;
Ok(State { total, current })
}
}

0 comments on commit 8894ad3

Please sign in to comment.