Skip to content

Commit

Permalink
Dont restart completed files. 2.0.3 dev
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyFFM committed Nov 3, 2018
1 parent c497659 commit 50ed567
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "engraver"
version = "2.0.2"
version = "2.0.3"
license = "GPL-3.0"
authors = ["PoC Consortium <[email protected]>"]
description = """
Expand Down
12 changes: 11 additions & 1 deletion src/plotter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,17 @@ impl Plotter {
if !task.quiet {
print!("File already exists, reading resume info...");
}
progress = read_resume_info(&file);
let resume_info = read_resume_info(&file);
match resume_info {
Ok(x) => progress = x,
Err(_) => {
println!("Error");
println!("File is already completed.");
println!("Shutting Down...");
return;

}
}
if !task.quiet {
println!("OK");
}
Expand Down
6 changes: 3 additions & 3 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn create_writer_task(
}
}

pub fn read_resume_info(file: &Path) -> u64 {
pub fn read_resume_info(file: &Path) -> Result<u64,u64> {
let mut file = open_r(&file).unwrap();
file.seek(SeekFrom::End(-8)).unwrap();

Expand All @@ -103,9 +103,9 @@ pub fn read_resume_info(file: &Path) -> u64 {
file.read_exact(&mut double_monkey[0..4]).unwrap();

if double_monkey == [0xAF, 0xFE, 0xAF, 0xFE] {
u64::from(as_u32_le(progress))
Ok(u64::from(as_u32_le(progress)))
} else {
0
Err(0)
}
}

Expand Down

0 comments on commit 50ed567

Please sign in to comment.