[all] Apply cargo fmt, and fix clippy warnings
This commit is contained in:
@@ -7,8 +7,8 @@ use std::process;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::cache::check::{check, CacheCheckOptions};
|
||||
use crate::report::*;
|
||||
use crate::commands::utils::*;
|
||||
use crate::report::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
@@ -76,7 +76,7 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
check_file_not_tiny(input_file, &report);
|
||||
|
||||
let opts = CacheCheckOptions {
|
||||
dev: &input_file,
|
||||
dev: input_file,
|
||||
async_io: matches.is_present("ASYNC_IO"),
|
||||
sb_only: matches.is_present("SB_ONLY"),
|
||||
skip_mappings: matches.is_present("SKIP_MAPPINGS"),
|
||||
|
||||
@@ -60,8 +60,8 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
check_input_file(input_file, &report);
|
||||
|
||||
let opts = CacheRepairOptions {
|
||||
input: &input_file,
|
||||
output: &output_file,
|
||||
input: input_file,
|
||||
output: output_file,
|
||||
async_io: matches.is_present("ASYNC_IO"),
|
||||
report: report.clone(),
|
||||
};
|
||||
|
||||
@@ -51,8 +51,8 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
check_output_file(output_file, &report);
|
||||
|
||||
let opts = CacheRestoreOptions {
|
||||
input: &input_file,
|
||||
output: &output_file,
|
||||
input: input_file,
|
||||
output: output_file,
|
||||
async_io: matches.is_present("ASYNC_IO"),
|
||||
report: report.clone(),
|
||||
};
|
||||
|
||||
@@ -5,9 +5,9 @@ use std::path::Path;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::commands::utils::*;
|
||||
use crate::io_engine::*;
|
||||
use crate::thin::check::{check, ThinCheckOptions, MAX_CONCURRENT_IO};
|
||||
use crate::commands::utils::*;
|
||||
|
||||
pub fn run(args: &[std::ffi::OsString]) {
|
||||
let parser = App::new("thin_check")
|
||||
@@ -88,7 +88,7 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
.index(1),
|
||||
);
|
||||
|
||||
let matches = parser.get_matches_from(args.into_iter());
|
||||
let matches = parser.get_matches_from(args.iter());
|
||||
let input_file = Path::new(matches.value_of("INPUT").unwrap());
|
||||
|
||||
let report = mk_report(matches.is_present("QUIET"));
|
||||
@@ -101,14 +101,13 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
|
||||
if matches.is_present("ASYNC_IO") {
|
||||
engine = Arc::new(
|
||||
AsyncIoEngine::new(&input_file, MAX_CONCURRENT_IO, writable)
|
||||
AsyncIoEngine::new(input_file, MAX_CONCURRENT_IO, writable)
|
||||
.expect("unable to open input file"),
|
||||
);
|
||||
} else {
|
||||
let nr_threads = std::cmp::max(8, num_cpus::get() * 2);
|
||||
engine = Arc::new(
|
||||
SyncIoEngine::new(&input_file, nr_threads, writable)
|
||||
.expect("unable to open input file"),
|
||||
SyncIoEngine::new(input_file, nr_threads, writable).expect("unable to open input file"),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
let report = std::sync::Arc::new(mk_simple_report());
|
||||
check_input_file(input_file, &report);
|
||||
|
||||
if let Err(reason) = crate::pack::toplevel::pack(&input_file, &output_file) {
|
||||
if let Err(reason) = crate::pack::toplevel::pack(input_file, output_file) {
|
||||
report.fatal(&format!("Application error: {}\n", reason));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
extern crate clap;
|
||||
|
||||
use crate::file_utils;
|
||||
use clap::{App, Arg};
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
use crate::file_utils;
|
||||
|
||||
use std::process::exit;
|
||||
|
||||
@@ -37,7 +37,7 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if let Err(reason) = crate::pack::toplevel::unpack(&input_file, &output_file) {
|
||||
if let Err(reason) = crate::pack::toplevel::unpack(input_file, output_file) {
|
||||
eprintln!("Application error: {}", reason);
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
});
|
||||
|
||||
let opts = ThinRepairOptions {
|
||||
input: &input_file,
|
||||
output: &output_file,
|
||||
input: input_file,
|
||||
output: output_file,
|
||||
async_io: matches.is_present("ASYNC_IO"),
|
||||
report: report.clone(),
|
||||
overrides: SuperblockOverrides {
|
||||
|
||||
@@ -51,8 +51,8 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
check_output_file(output_file, &report);
|
||||
|
||||
let opts = ThinRestoreOptions {
|
||||
input: &input_file,
|
||||
output: &output_file,
|
||||
input: input_file,
|
||||
output: output_file,
|
||||
async_io: matches.is_present("ASYNC_IO"),
|
||||
report: report.clone(),
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ pub fn run(args: &[std::ffi::OsString]) {
|
||||
check_input_file(input_file, &report);
|
||||
|
||||
if let Err(reason) =
|
||||
crate::shrink::toplevel::shrink(&input_file, &output_file, &data_file, size, do_copy)
|
||||
crate::shrink::toplevel::shrink(input_file, output_file, data_file, size, do_copy)
|
||||
{
|
||||
eprintln!("Application error: {}\n", reason);
|
||||
exit(1);
|
||||
|
||||
@@ -10,10 +10,7 @@ use crate::report::*;
|
||||
|
||||
pub fn check_input_file(input_file: &Path, report: &Report) {
|
||||
if !file_utils::file_exists(input_file) {
|
||||
report.fatal(&format!(
|
||||
"Couldn't find input file '{:?}'.",
|
||||
&input_file
|
||||
));
|
||||
report.fatal(&format!("Couldn't find input file '{:?}'.", &input_file));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -62,15 +59,11 @@ pub fn mk_report(quiet: bool) -> std::sync::Arc<Report> {
|
||||
}
|
||||
|
||||
fn is_xml(line: &[u8]) -> bool {
|
||||
line.starts_with(b"<superblock") ||
|
||||
line.starts_with(b"?xml") ||
|
||||
line.starts_with(b"<!DOCTYPE")
|
||||
line.starts_with(b"<superblock") || line.starts_with(b"?xml") || line.starts_with(b"<!DOCTYPE")
|
||||
}
|
||||
|
||||
pub fn check_not_xml_(input_file: &Path, report: &Report) -> Result<()> {
|
||||
let mut file = OpenOptions::new()
|
||||
.read(true)
|
||||
.open(input_file)?;
|
||||
let mut file = OpenOptions::new().read(true).open(input_file)?;
|
||||
let mut data = vec![0; 16];
|
||||
file.read_exact(&mut data)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user