feat: RefCell remove

This commit is contained in:
MisileLaboratory 2023-04-18 04:05:11 +00:00 committed by João Marcos
parent f2b984bc7a
commit 2ebdaf6ecf
2 changed files with 4 additions and 5 deletions

View File

@ -34,7 +34,7 @@ unrar = "0.5.2"
xz2 = "0.1.7" xz2 = "0.1.7"
zip = { version = "0.6.6", default-features = false, features = ["time"] } zip = { version = "0.6.6", default-features = false, features = ["time"] }
zstd = { version = "0.13.0", default-features = false } zstd = { version = "0.13.0", default-features = false }
sevenz-rust = {version = "0.2.9", features = ["compress"]} sevenz-rust = {version = "0.2.10", features = ["compress"]}
[target.'cfg(not(unix))'.dependencies] [target.'cfg(not(unix))'.dependencies]
is_executable = "1.0.1" is_executable = "1.0.1"

View File

@ -1,5 +1,4 @@
use std::{ use std::{
cell::RefCell,
io::{self, BufReader, Read}, io::{self, BufReader, Read},
path::Path, path::Path,
}; };
@ -89,17 +88,17 @@ pub fn list_archive_contents(
} }
}, },
SevenZip => { SevenZip => {
let a = RefCell::new(Vec::new()); let mut a = Vec::new();
sevenz_rust::decompress_file_with_extract_fn(archive_path, ".", |entry, _, _| { sevenz_rust::decompress_file_with_extract_fn(archive_path, ".", |entry, _, _| {
a.borrow_mut().push(Ok(FileInArchive { a.push(Ok(FileInArchive {
path: entry.name().into(), path: entry.name().into(),
is_dir: entry.is_directory(), is_dir: entry.is_directory(),
})); }));
Ok(true) Ok(true)
}) })
.map_err(|e| crate::Error::SevenzipError(e))?; .map_err(|e| crate::Error::SevenzipError(e))?;
Box::new(a.into_inner().into_iter()) Box::new(a.into_iter())
} }
Gzip | Bzip | Lz4 | Lzma | Snappy | Zstd => { Gzip | Bzip | Lz4 | Lzma | Snappy | Zstd => {
panic!("Not an archive! This should never happen, if it does, something is wrong with `CompressionFormat::is_archive()`. Please report this error!"); panic!("Not an archive! This should never happen, if it does, something is wrong with `CompressionFormat::is_archive()`. Please report this error!");