Skip to content

Commit

Permalink
VecDeque makes more sense to maintain order of operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ellieplayswow committed Feb 3, 2025
1 parent a4d7a37 commit b4dae4b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/operation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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)) {
Expand All @@ -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)?;
}

Expand Down Expand Up @@ -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)?;
}

Expand Down

0 comments on commit b4dae4b

Please sign in to comment.