Skip to content

Commit 9cca679

Browse files
committed
fix: do not crash when we want extract dialog with multiple archive files
1 parent 180c721 commit 9cca679

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/app.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,10 @@ impl App {
770770
fn open_file(&mut self, paths: &[impl AsRef<Path>]) -> Task<Message> {
771771
let mut tasks = Vec::new();
772772

773+
// This will be, at the end of the function, a list of all archives that
774+
// don't have a suitable app
775+
let mut found_archives_paths: Vec<PathBuf> = vec![];
776+
773777
// Associate all paths to its MIME type
774778
// This allows handling paths as groups if possible, such as launching a single video
775779
// player that is passed every path.
@@ -804,7 +808,7 @@ impl App {
804808
match spawn_detached(&mut command) {
805809
Ok(()) => {
806810
log::debug!("Launched {} with {:?}", app.id, paths);
807-
// Aggiorna recently_used
811+
// Updates recently_used
808812
for path in &paths {
809813
let _ = recently_used_xbel::update_recently_used(
810814
path,
@@ -827,7 +831,7 @@ impl App {
827831

828832
if !found_archive_app {
829833
log::info!("No suitable archive app found for MIME {}. Falling back to extract_to.", mime);
830-
tasks.push(self.extract_to(&paths));
834+
found_archives_paths.extend(paths.iter().cloned());
831835
}
832836

833837
continue 'outer;
@@ -894,6 +898,11 @@ impl App {
894898
}
895899
}
896900

901+
if found_archives_paths.len() > 0 {
902+
log::debug!("Paths to extract with dialog: {:?}", found_archives_paths);
903+
tasks.push(self.extract_to(&found_archives_paths));
904+
}
905+
897906
Task::batch(tasks)
898907
}
899908

0 commit comments

Comments
 (0)