mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
rustfmt
This commit is contained in:
parent
234e0406a1
commit
91f411439a
@ -5,8 +5,8 @@ use tar::Builder;
|
|||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use super::compressor::Entry;
|
use super::compressor::Entry;
|
||||||
use crate::{compressors::Compressor, file::File};
|
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
|
use crate::{compressors::Compressor, file::File};
|
||||||
|
|
||||||
pub struct TarCompressor {}
|
pub struct TarCompressor {}
|
||||||
|
|
||||||
@ -21,7 +21,6 @@ impl TarCompressor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_archive_from_files(input_filenames: Vec<PathBuf>) -> crate::Result<Vec<u8>> {
|
fn make_archive_from_files(input_filenames: Vec<PathBuf>) -> crate::Result<Vec<u8>> {
|
||||||
|
|
||||||
let buf = Vec::new();
|
let buf = Vec::new();
|
||||||
let mut b = Builder::new(buf);
|
let mut b = Builder::new(buf);
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
use std::{io::{Cursor, Write}, path::PathBuf};
|
use std::{
|
||||||
|
io::{Cursor, Write},
|
||||||
|
path::PathBuf,
|
||||||
|
};
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
@ -52,7 +55,6 @@ impl ZipCompressor {
|
|||||||
zip::write::FileOptions::default().compression_method(zip::CompressionMethod::Deflated);
|
zip::write::FileOptions::default().compression_method(zip::CompressionMethod::Deflated);
|
||||||
|
|
||||||
for filename in input_filenames {
|
for filename in input_filenames {
|
||||||
|
|
||||||
let previous_location = utils::change_dir_and_return_parent(&filename)?;
|
let previous_location = utils::change_dir_and_return_parent(&filename)?;
|
||||||
let filename = filename
|
let filename = filename
|
||||||
.file_name()
|
.file_name()
|
||||||
|
23
src/utils.rs
23
src/utils.rs
@ -1,4 +1,7 @@
|
|||||||
use std::{env, fs, path::{Path, PathBuf}};
|
use std::{
|
||||||
|
env, fs,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
|
|
||||||
@ -61,16 +64,26 @@ pub(crate) fn get_destination_path(dest: &Option<File>) -> &Path {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub (crate) fn change_dir_and_return_parent(filename: &PathBuf) -> crate::Result<PathBuf> {
|
pub(crate) fn change_dir_and_return_parent(filename: &PathBuf) -> crate::Result<PathBuf> {
|
||||||
let previous_location = env::current_dir()?;
|
let previous_location = env::current_dir()?;
|
||||||
|
|
||||||
let parent = if let Some(parent) = filename.parent() {
|
let parent = if let Some(parent) = filename.parent() {
|
||||||
parent
|
parent
|
||||||
} else {
|
} else {
|
||||||
let spacing = " ";
|
let spacing = " ";
|
||||||
println!("{} It seems you're trying to compress the root folder.", "[WARNING]".red());
|
println!(
|
||||||
println!("{}This is unadvisable since ouch does compressions in-memory.", spacing);
|
"{} It seems you're trying to compress the root folder.",
|
||||||
println!("{}Use a more appropriate tool for this, such as {}.", spacing, "rsync".green());
|
"[WARNING]".red()
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"{}This is unadvisable since ouch does compressions in-memory.",
|
||||||
|
spacing
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"{}Use a more appropriate tool for this, such as {}.",
|
||||||
|
spacing,
|
||||||
|
"rsync".green()
|
||||||
|
);
|
||||||
return Err(crate::Error::InvalidInput);
|
return Err(crate::Error::InvalidInput);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user