fix: clippy lints
This commit is contained in:
Submodule libraries/droplet/libarchive-rust updated: bf47426655...fdb73ef2de
@@ -1,4 +1,4 @@
|
||||
use std::{env, os::unix::fs::MetadataExt, path::PathBuf};
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
use droplet_rs::manifest::generate_manifest_rusty;
|
||||
use tokio::runtime::Handle;
|
||||
@@ -11,7 +11,7 @@ pub async fn main() {
|
||||
let metrics = Handle::current().metrics();
|
||||
println!("using {} workers", metrics.num_workers());
|
||||
|
||||
let manifest = generate_manifest_rusty(
|
||||
let _manifest = generate_manifest_rusty(
|
||||
&target_dir,
|
||||
|progress| println!("PROGRESS: {}", progress),
|
||||
|message| {
|
||||
@@ -21,37 +21,4 @@ pub async fn main() {
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
return;
|
||||
|
||||
// Sanity checks
|
||||
for (_, chunk_data) in manifest.chunks {
|
||||
for file in chunk_data.files {
|
||||
let path = target_dir.join(file.filename);
|
||||
if !path.exists() {
|
||||
panic!("{} doesn't exist", path.display());
|
||||
}
|
||||
|
||||
let metadata = path.metadata().expect("failed to fetch metadata");
|
||||
let file_size = metadata.size();
|
||||
if file.start > file_size as usize {
|
||||
panic!(
|
||||
"start for {} doesn't make sense: start: {}, size: {}",
|
||||
path.display(),
|
||||
file.start,
|
||||
file_size
|
||||
);
|
||||
}
|
||||
|
||||
let end_position = file.start + file.length;
|
||||
if end_position > file_size as usize {
|
||||
panic!(
|
||||
"end for {} doesn't make sense: end: {}, size: {}",
|
||||
path.display(),
|
||||
end_position,
|
||||
file_size
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
future::Future,
|
||||
mem,
|
||||
path::Path,
|
||||
sync::{
|
||||
@@ -146,8 +145,8 @@ pub async fn generate_manifest_rusty<T: Fn(String), V: Fn(f32)>(
|
||||
let total_manifest_length = Arc::new(AtomicU64::new(0));
|
||||
|
||||
// SAFETY: we .join_all() the futures using this
|
||||
let backend: &'static Box<dyn VersionBackend + Send + Sync> =
|
||||
unsafe { mem::transmute(&backend) };
|
||||
let backend: &'static (dyn VersionBackend + Send + Sync) =
|
||||
unsafe { mem::transmute(&*backend) };
|
||||
|
||||
let mut futures: JoinSet<Result<(), anyhow::Error>> = JoinSet::new();
|
||||
let (send_log, mut recieve_log) = tokio::sync::mpsc::channel(16);
|
||||
|
||||
@@ -19,7 +19,7 @@ fn manifest_gen(resource: &str) {
|
||||
runtime.block_on(async move {
|
||||
let filepath = Path::new(resource);
|
||||
let manifest = generate_manifest_rusty(
|
||||
&filepath,
|
||||
filepath,
|
||||
|_| {},
|
||||
|message| {
|
||||
println!("({}) {}", filepath.display(), message);
|
||||
@@ -27,10 +27,13 @@ fn manifest_gen(resource: &str) {
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.expect(&format!(
|
||||
"failed to generate manifest for {}",
|
||||
filepath.display()
|
||||
));
|
||||
.unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"failed to generate manifest for {}: {:?}",
|
||||
filepath.display(),
|
||||
err
|
||||
)
|
||||
});
|
||||
|
||||
let mut output_path = filepath.to_path_buf();
|
||||
output_path.set_extension("json");
|
||||
|
||||
@@ -49,7 +49,7 @@ impl AsyncRead for ArchiveReader {
|
||||
};
|
||||
|
||||
buf.put_slice(block);
|
||||
return Poll::Ready(Ok(()));
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,12 @@ pub fn _list_files(vec: &mut Vec<PathBuf>, path: &Path) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const SUPPORTED_FILE_EXTENSIONS: [&'static str; 11] = [
|
||||
const SUPPORTED_FILE_EXTENSIONS: [&str; 11] = [
|
||||
"tar", "pax", "cpio", "zip", "jar", "ar", "xar", "rar", "rpm", "7z", "iso",
|
||||
];
|
||||
|
||||
pub mod types;
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn create_backend_constructor<'a>(
|
||||
path: &Path,
|
||||
) -> Option<Box<dyn FnOnce() -> Result<Box<dyn VersionBackend + Send + Sync + 'a>>>> {
|
||||
@@ -48,11 +49,10 @@ pub fn create_backend_constructor<'a>(
|
||||
}));
|
||||
};
|
||||
|
||||
let file_extension = path.extension().map(|v| v.to_str()).flatten()?;
|
||||
let file_extension = path.extension().and_then(|v| v.to_str())?;
|
||||
|
||||
if SUPPORTED_FILE_EXTENSIONS
|
||||
.iter()
|
||||
.any(|v| *v == file_extension)
|
||||
.contains(&file_extension)
|
||||
{
|
||||
let buf = path.to_path_buf();
|
||||
return Some(Box::new(move || Ok(Box::new(ZipVersionBackend::new(buf)?))));
|
||||
|
||||
Reference in New Issue
Block a user