info = files + '.trashinfo'
This commit is contained in:
parent
388c9e4452
commit
1835637071
3 changed files with 10 additions and 5 deletions
|
@ -113,12 +113,13 @@ fn main() {
|
|||
|
||||
let stdin = io::stdin();
|
||||
let mut s = String::new();
|
||||
println!("which file to restore? [0..{}]", files.len());
|
||||
println!("which file to restore? [0..{}]", files.len() - 1);
|
||||
stdin.read_line(&mut s).unwrap();
|
||||
|
||||
match s.trim_end().parse::<usize>() {
|
||||
Ok(i) if i < files.len() => {
|
||||
let info = files.get(i).unwrap();
|
||||
println!("moving {:?} to {:?}", &info.deleted_path, &info.path);
|
||||
fs::rename(&info.deleted_path, &info.path);
|
||||
}
|
||||
_ => println!("Invalid number."),
|
||||
|
|
|
@ -51,13 +51,13 @@ pub fn put(path: impl AsRef<Path>, recursive: bool) -> Result<(), Error> {
|
|||
|
||||
let home_trash = TrashDir::get_home_trash();
|
||||
let file_name = format!(
|
||||
"{}.{}.trashinfo",
|
||||
"{}.{}",
|
||||
elapsed,
|
||||
path.file_name().unwrap().to_str().unwrap()
|
||||
);
|
||||
|
||||
let trash_file_path = home_trash.files_dir()?.join(&file_name);
|
||||
let trash_info_path = home_trash.info_dir()?.join(&file_name);
|
||||
let trash_info_path = home_trash.info_dir()?.join(file_name + ".trashinfo");
|
||||
|
||||
let trash_info = TrashInfo {
|
||||
path: path.clone(),
|
||||
|
|
|
@ -65,8 +65,12 @@ impl Iterator for TrashDirIter {
|
|||
entry
|
||||
};
|
||||
|
||||
let name = entry.path().file_name().unwrap();
|
||||
let deleted_path = self.0.join("files").join(name);
|
||||
let name = entry.path().file_name().unwrap().to_str().unwrap();
|
||||
let deleted_path = if !name.ends_with(".trashinfo") {
|
||||
return self.next();
|
||||
} else {
|
||||
self.0.join("files").join(name.trim_right_matches(".trashinfo"))
|
||||
};
|
||||
Some(TrashInfo::from_files(entry.path(), deleted_path).map_err(Error::from))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue