mirror of
https://github.com/nivekuil/rip
synced 2024-11-10 06:04:17 +00:00
Fix not rewinding file before re-reading it
This commit is contained in:
parent
79079dbff9
commit
f987ff53cc
1 changed files with 8 additions and 4 deletions
|
@ -15,6 +15,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::io::{Seek, SeekFrom};
|
||||||
use std::io::{Read, Write, BufRead, BufReader};
|
use std::io::{Read, Write, BufRead, BufReader};
|
||||||
use std::os::unix::fs::{FileTypeExt, PermissionsExt};
|
use std::os::unix::fs::{FileTypeExt, PermissionsExt};
|
||||||
include!("util.rs");
|
include!("util.rs");
|
||||||
|
@ -112,7 +113,7 @@ Send files to the graveyard (/tmp/graveyard-$USER by default) instead of unlinki
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through the graveyard and exhume all the graves
|
// Go through the graveyard and exhume all the graves
|
||||||
if let Ok(f) = fs::File::open(record) {
|
if let Ok(mut f) = fs::File::open(record) {
|
||||||
for line in lines_of_graves(&f, graves_to_exhume) {
|
for line in lines_of_graves(&f, graves_to_exhume) {
|
||||||
let entry: RecordItem = record_entry(&line);
|
let entry: RecordItem = record_entry(&line);
|
||||||
let orig: &Path = &{
|
let orig: &Path = &{
|
||||||
|
@ -128,11 +129,14 @@ Send files to the graveyard (/tmp/graveyard-$USER by default) instead of unlinki
|
||||||
println!("Returned {} to {}", entry.dest, orig.display());
|
println!("Returned {} to {}", entry.dest, orig.display());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Rewind the file for deletion
|
||||||
|
if f.seek(SeekFrom::Start(0)).is_ok() {
|
||||||
// Go through the record and remove all the exhumed graves
|
// Go through the record and remove all the exhumed graves
|
||||||
if let Err(e) = delete_lines_from_record(f, record, graves_to_exhume) {
|
if let Err(e) = delete_lines_from_record(f, record, graves_to_exhume) {
|
||||||
println!("Failed to remove unburied files from record: {}", e);
|
println!("Failed to remove unburied files from record: {}", e);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue