This commit is contained in:
2023-09-14 21:55:15 +02:00
parent 742c70e1df
commit 5fb4f6b7a7
6 changed files with 67 additions and 200 deletions

View File

@@ -11,7 +11,7 @@ pub fn get_minio() -> Minio {
);
Minio::builder()
.host(&config::CONFIG.minio_host)
.endpoint(&config::CONFIG.minio_host)
.provider(provider)
.secure(false)
.build()

View File

@@ -55,7 +55,7 @@ where
pub async fn set_task_error(key: String, error_message: String) {
let task = Task {
id: key.clone(),
status: crate::structures::TaskStatus::Failled,
status: crate::structures::TaskStatus::Failed,
status_description: "Ошибка!".to_string(),
error_message: Some(error_message),
result_filename: None,
@@ -97,7 +97,8 @@ pub async fn upload_to_minio(archive: SpooledTempFile, filename: String) -> Resu
if let Err(err) = minio.put_object_stream(
ObjectArgs::new(&config::CONFIG.minio_bucket, filename.clone()),
Box::pin(data_stream)
Box::pin(data_stream),
None
).await {
return Err(Box::new(err));
}

View File

@@ -9,7 +9,7 @@ pub enum TaskStatus {
InProgress,
Archiving,
Complete,
Failled
Failed
}
#[derive(Serialize, Deserialize, Clone, Debug)]

View File

@@ -1,6 +1,6 @@
use std::time::Duration;
use axum::{Router, routing::{get, post}, middleware::{self, Next}, http::{Request, StatusCode, self}, response::{Response, IntoResponse}, extract::{Path, self}, Json};
use axum::{Router, routing::{get, post}, middleware::{self, Next}, http::{Request, StatusCode, self}, response::{Response, IntoResponse}, extract::{Path}, Json};
use axum_prometheus::PrometheusMetricLayer;
use moka::future::Cache;
use once_cell::sync::Lazy;
@@ -20,13 +20,13 @@ pub static TASK_RESULTS: Lazy<Cache<String, Task>> = Lazy::new(|| {
async fn create_archive_task(
extract::Json(data): extract::Json<CreateTask>
Json(data): Json<CreateTask>
) -> impl IntoResponse {
let key = get_key(data.clone());
let result = match TASK_RESULTS.get(&key) {
Some(result) => {
if result.status == TaskStatus::Failled {
if result.status == TaskStatus::Failed {
create_task(data).await
} else {
result