VecDeque makes more sense to maintain order of operations
This commit is contained in:
parent
a4d7a377d3
commit
b4dae4bfa8
1 changed files with 5 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt::{Formatter};
|
||||
use tokio::sync::{mpsc, Mutex as TokioMutex};
|
||||
use walkdir::WalkDir;
|
||||
|
|
@ -119,7 +120,7 @@ fn zip_extract<R: io::Read + io::Seek, P: AsRef<Path>>(
|
|||
let mut files_by_unix_mode = Vec::new();
|
||||
let mut buffer = vec![0; 4 * 1024 * 1024];
|
||||
let total_files = archive.len();
|
||||
let mut pending_directory_creates = Vec::new();
|
||||
let mut pending_directory_creates = VecDeque::new();
|
||||
|
||||
for i in 0..total_files {
|
||||
controller
|
||||
|
|
@ -139,7 +140,7 @@ fn zip_extract<R: io::Read + io::Seek, P: AsRef<Path>>(
|
|||
let outpath = directory.as_ref().join(filepath);
|
||||
|
||||
if file.is_dir() {
|
||||
pending_directory_creates.push(outpath.clone());
|
||||
pending_directory_creates.push_back(outpath.clone());
|
||||
continue;
|
||||
}
|
||||
let symlink_target = if file.is_symlink() && (cfg!(unix) || cfg!(windows)) {
|
||||
|
|
@ -152,7 +153,7 @@ fn zip_extract<R: io::Read + io::Seek, P: AsRef<Path>>(
|
|||
drop(file);
|
||||
if let Some(target) = symlink_target {
|
||||
// create all pending dirs
|
||||
while let Some(pending_dir) = pending_directory_creates.pop() {
|
||||
while let Some(pending_dir) = pending_directory_creates.pop_front() {
|
||||
make_writable_dir_all(pending_dir)?;
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +197,7 @@ fn zip_extract<R: io::Read + io::Seek, P: AsRef<Path>>(
|
|||
}.map_err(|e| e)?;
|
||||
|
||||
// create all pending dirs
|
||||
while let Some(pending_dir) = pending_directory_creates.pop() {
|
||||
while let Some(pending_dir) = pending_directory_creates.pop_front() {
|
||||
make_writable_dir_all(pending_dir)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue