diff --git a/src/maple/gtfs_handlers/flatten.rs b/src/maple/gtfs_handlers/flatten.rs index 44219e25..a85dd493 100644 --- a/src/maple/gtfs_handlers/flatten.rs +++ b/src/maple/gtfs_handlers/flatten.rs @@ -4,6 +4,19 @@ use std::fs::File; use std::io::Cursor; use std::io::Read; use std::path::PathBuf; +use std::fs::{read_dir, remove_file}; + +fn delete_zip_files(dir_path: &str) -> std::io::Result<()> { + for entry in read_dir(dir_path)? { + let entry = entry?; + let path = entry.path(); + if path.is_file() && path.extension().map_or(false, |ext| ext == "zip") { + // don't crash if you can't delete the zips + let _ = remove_file(path); + } + } + Ok(()) + } // Extracts a sub zip file and uses it as the parent folder pub fn extract_sub_zip(feed_id: &str, sub_folder: &str) -> Result<(), Box> { @@ -16,10 +29,13 @@ pub fn extract_sub_zip(feed_id: &str, sub_folder: &str) -> Result<(), Box