cargo fmt + bump version
This commit is contained in:
parent
02ba29053b
commit
6e055b1efd
7 changed files with 13 additions and 16 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -69,7 +69,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "garbage"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "garbage"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
authors = ["Michael Zhang <iptq@protonmail.com>"]
|
||||
description = "cli tool for interacting with the freedesktop trashcan"
|
||||
license = "MIT"
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::os::unix::ffi::OsStrExt;
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use chrono::{DateTime, Local, TimeZone};
|
||||
use percent_encoding::{percent_decode, };
|
||||
use percent_encoding::percent_decode;
|
||||
|
||||
use crate::errors::{Error, TrashInfoError};
|
||||
use crate::utils;
|
||||
|
@ -107,11 +107,7 @@ impl TrashInfo {
|
|||
/// Write the current TrashInfo into a .trashinfo file.
|
||||
pub fn write(&self, mut out: impl Write) -> Result<(), io::Error> {
|
||||
writeln!(out, "[Trash Info]")?;
|
||||
writeln!(
|
||||
out,
|
||||
"Path={}",
|
||||
utils::percent_encode(&self.path)
|
||||
)?;
|
||||
writeln!(out, "Path={}", utils::percent_encode(&self.path))?;
|
||||
writeln!(
|
||||
out,
|
||||
"DeletionDate={}",
|
||||
|
|
|
@ -2,8 +2,8 @@ use std::path::PathBuf;
|
|||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::TrashDir;
|
||||
use crate::utils;
|
||||
use crate::TrashDir;
|
||||
|
||||
/// Options to pass to list
|
||||
#[derive(StructOpt)]
|
||||
|
@ -31,7 +31,11 @@ pub fn list(options: ListOptions) -> Result<()> {
|
|||
.collect::<Vec<_>>();
|
||||
files.sort_unstable_by_key(|info| info.deletion_date);
|
||||
for info in files {
|
||||
println!("{}\t{}", info.deletion_date, utils::percent_encode(info.path));
|
||||
println!(
|
||||
"{}\t{}",
|
||||
info.deletion_date,
|
||||
utils::percent_encode(info.path)
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -15,7 +15,6 @@ use crate::{HOME_MOUNT, MOUNTS};
|
|||
pub enum Error {
|
||||
// #[error("Refusing to remove directory {0} without '-r' option")]
|
||||
// MissingRecursiveOption(PathBuf),
|
||||
|
||||
#[error("Refusing to remove '.' or '..', skipping...")]
|
||||
CannotTrashDotDirs,
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ use std::path::PathBuf;
|
|||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::TrashDir;
|
||||
use crate::utils;
|
||||
use crate::TrashDir;
|
||||
|
||||
/// Options to pass to restore
|
||||
#[derive(StructOpt)]
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::os::unix::ffi::OsStrExt;
|
|||
use std::path::{Path, PathBuf, MAIN_SEPARATOR};
|
||||
|
||||
use anyhow::Result;
|
||||
use percent_encoding::{AsciiSet};
|
||||
use percent_encoding::AsciiSet;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
const MASK: &AsciiSet = percent_encoding::CONTROLS;
|
||||
|
@ -59,9 +59,7 @@ pub fn recursive_copy(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()
|
|||
pub fn percent_encode(path: impl AsRef<Path>) -> String {
|
||||
let path = path.as_ref();
|
||||
path.iter()
|
||||
.map(|segment| {
|
||||
percent_encoding::percent_encode(segment.as_bytes(), MASK).to_string()
|
||||
})
|
||||
.map(|segment| percent_encoding::percent_encode(segment.as_bytes(), MASK).to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(&MAIN_SEPARATOR.to_string())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue