From 6bb758da0f7ebb1149dc74ce684d2c37a844975b Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Sat, 12 Aug 2023 01:38:02 +0200 Subject: [PATCH] Fix --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 309ecb0..9975698 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ -use std::{net::SocketAddr, time::SystemTime, str::FromStr}; +use std::{net::SocketAddr, time::{SystemTime, Duration}, str::FromStr}; use axum::{Router, routing::{post, get}, extract::Multipart, response::{IntoResponse, AppendHeaders, Response}, http::{StatusCode, header, Request, self}, body::StreamBody, middleware::{Next, self}}; use axum_prometheus::PrometheusMetricLayer; use sentry::{ClientOptions, types::Dsn, integrations::debug_images::DebugImagesIntegration}; -use tokio::{fs::{remove_file, read_dir, remove_dir, File}, io::{AsyncWriteExt, copy}, process::Command}; +use tokio::{fs::{remove_file, read_dir, remove_dir, File}, io::{AsyncWriteExt, copy}, process::Command, time::sleep}; use tower_http::trace::{TraceLayer, self}; use tracing::{info, log, Level}; use async_tempfile::TempFile; @@ -156,7 +156,10 @@ async fn convert_file( ) ]); - tokio::spawn(remove_temp_files()); + tokio::spawn(async { + sleep(Duration::from_secs(60 * 60)).await; + remove_temp_files().await + }); (headers, body).into_response() }