fix: remove folder just before installing package

This commit is contained in:
anatawa12 2023-01-23 19:17:40 +09:00
commit c493b6328a
No known key found for this signature in database
GPG key ID: 9CA909848B8E4EA6

View file

@ -20,7 +20,7 @@ use std::future::Future;
use std::io::SeekFrom;
use std::path::{Path, PathBuf};
use std::{env, fmt, io};
use tokio::fs::{create_dir_all, read_dir, File, OpenOptions};
use tokio::fs::{create_dir_all, read_dir, remove_dir_all, File, OpenOptions};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
pub mod structs;
@ -262,6 +262,9 @@ impl Environment {
cache_file
};
// remove dest folder before extract if exists
remove_dir_all(dest_folder).await.ok();
// extract zip file
// TODO: sanitize to prevent directory traversal
let mut zip_reader = async_zip::read::seek::ZipFileReader::new(zip_file)