cargo fmt + bump version

This commit is contained in:
Michael Zhang 2020-06-05 23:32:34 -05:00
parent 02ba29053b
commit 6e055b1efd
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
7 changed files with 13 additions and 16 deletions

2
Cargo.lock generated
View file

@ -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)",

View file

@ -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"

View file

@ -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={}",

View file

@ -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(())

View file

@ -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,

View file

@ -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)]

View file

@ -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())
}