fix: some small bugs
This commit is contained in:
parent
6610442bf1
commit
1203a34f8f
3 changed files with 14 additions and 5 deletions
|
|
@ -25,6 +25,8 @@ impl Error for ServerError {}
|
|||
|
||||
impl IntoResponse for ServerError {
|
||||
fn into_response(self) -> Response {
|
||||
tracing::error!("{}", self);
|
||||
|
||||
match self {
|
||||
ServerError::IO(_) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
ServerError::Axum(_) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ pub fn app(
|
|||
// file doesn't exist, then we look for it in the other directories.
|
||||
let serve_dir = ServeDir::new(ctx.static_dir.join(STATIC_ROOT_NAME))
|
||||
.append_index_html_on_directories(true)
|
||||
.not_found_service(
|
||||
ServeDir::new(ctx.static_dir.clone()).append_index_html_on_directories(true),
|
||||
);
|
||||
.fallback(ServeDir::new(ctx.static_dir.clone()).append_index_html_on_directories(true));
|
||||
|
||||
let mut app = Router::new()
|
||||
.route_service("/", serve_dir.clone())
|
||||
|
|
@ -101,8 +99,13 @@ fn process_archive(ar_path: &Path, dest_dir: &Path) -> io::Result<()> {
|
|||
.unwrap_or(String::from(""));
|
||||
let new_dir = dest_dir.with_extension(format!("{ext}.new"));
|
||||
|
||||
// Directory might be left behind by previous failed upload
|
||||
if new_dir.try_exists()? {
|
||||
std::fs::remove_dir_all(&new_dir)?;
|
||||
}
|
||||
|
||||
// Unpack archive into new directory
|
||||
std::fs::create_dir(&new_dir)?;
|
||||
std::fs::create_dir_all(&new_dir)?;
|
||||
ar.unpack(&new_dir)?;
|
||||
|
||||
// Replace original directory with new one
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue