deny warnings

This commit is contained in:
Michael Zhang 2019-12-27 19:37:22 -06:00
parent b55751f2c0
commit 70d983be98
No known key found for this signature in database
GPG key ID: 5BAEFE5D04F0CE6C
6 changed files with 17 additions and 16 deletions

View file

@ -1,6 +1,7 @@
#![deny(warnings)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
#[macro_use]
extern crate anyhow;
@ -14,7 +15,6 @@ mod mounts;
pub mod ops;
mod utils;
use std::io;
use std::path::PathBuf;
use xdg::BaseDirectories;

View file

@ -1,4 +1,5 @@
#[macro_use]
#![deny(warnings)]
extern crate anyhow;
use std::fs;
@ -75,7 +76,7 @@ fn run() -> Result<()> {
paths,
recursive,
force,
} => ops::put(paths, recursive),
} => ops::put(paths, recursive, force),
Command::Restore => {
let home_trash = TrashDir::get_home_trash();
let mut files = home_trash

View file

@ -1,5 +1,4 @@
use std::borrow::Cow;
use std::env;
use std::ffi::OsStr;
use std::fs::File;
use std::io::Read;

View file

@ -4,7 +4,6 @@ use anyhow::Result;
use chrono::{Duration, Local};
use crate::TrashDir;
use crate::TrashInfo;
pub fn empty(dry: bool, days: Option<u32>) -> Result<()> {
let home_trash = TrashDir::get_home_trash();

View file

@ -4,7 +4,7 @@ use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};
use anyhow::Result;
use chrono::{Duration, Local};
use chrono::{Local};
use crate::utils;
use crate::TrashDir;
@ -17,7 +17,7 @@ pub enum Error {
CannotTrashDotDirs,
}
pub fn put(paths: Vec<PathBuf>, recursive: bool) -> Result<()> {
pub fn put(paths: Vec<PathBuf>, _recursive: bool, _force: bool) -> Result<()> {
let strategy = DeletionStrategy::Copy;
for path in paths {
if let Err(err) = strategy.delete(path) {
@ -28,6 +28,8 @@ pub fn put(paths: Vec<PathBuf>, recursive: bool) -> Result<()> {
Ok(())
}
// TODO: implement the other ones
#[allow(dead_code)]
pub enum DeletionStrategy {
Copy,
Topdir,
@ -41,7 +43,7 @@ impl DeletionStrategy {
path: impl AsRef<Path>,
) -> Option<(TrashDir, bool)> {
let mount = mount.as_ref();
let path = path.as_ref();
let _path = path.as_ref();
// first, are we on the home mount?
if mount == *HOME_MOUNT {
@ -155,7 +157,7 @@ impl DeletionStrategy {
// copy the file over
if copy {
utils::recursive_copy(&target, &trash_file_path)?;
fs::remove_dir_all(&target);
fs::remove_dir_all(&target)?;
} else {
fs::rename(&target, &trash_file_path)?;
}

View file

@ -2,10 +2,10 @@ use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use anyhow::Error;
use anyhow::Result;
use walkdir::WalkDir;
pub fn into_absolute(path: impl AsRef<Path>) -> Result<PathBuf, Error> {
pub fn into_absolute(path: impl AsRef<Path>) -> Result<PathBuf> {
let path = path.as_ref();
Ok(if !path.is_absolute() {
@ -19,7 +19,7 @@ pub fn get_uid() -> u64 {
unsafe { libc::getuid().into() }
}
pub fn recursive_copy(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<(), Error> {
pub fn recursive_copy(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> {
let src = src.as_ref();
let dst = dst.as_ref();
@ -34,15 +34,15 @@ pub fn recursive_copy(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()
// this must be the root
if let None = relative_path.file_name() {
fs::create_dir(dst);
fs::create_dir(dst)?;
continue;
}
let target_name = dst.join(relative_path);
if path.is_dir() {
fs::create_dir(&target_name);
fs::create_dir(&target_name)?;
} else {
fs::copy(path, &target_name);
fs::copy(path, &target_name)?;
}
}