diff --git a/Cargo.lock b/Cargo.lock index bffebad59..7efb0f3a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3340,9 +3340,9 @@ dependencies = [ [[package]] name = "sogar-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c22e32057677b2ae1773e28d709bea34a8d162cd8361e51b0d5e189df633f2" +checksum = "f03ca9234022941163776929dcdea5c47d14995229138c07cf1c33da8cc84db6" dependencies = [ "clap 2.33.3", "config", diff --git a/devolutions-gateway/src/http/controllers/sogar_token.rs b/devolutions-gateway/src/http/controllers/sogar_token.rs index a60d04877..301f2fea6 100644 --- a/devolutions-gateway/src/http/controllers/sogar_token.rs +++ b/devolutions-gateway/src/http/controllers/sogar_token.rs @@ -1,14 +1,11 @@ use crate::config::{Config, SogarUser}; -use picky::{ - jose::{jws::JwsAlg, jwt::JwtSig}, - key::PrivateKey, -}; -use saphir::{ - controller::Controller, - http::{Method, StatusCode}, - macros::controller, - prelude::Request, -}; +use picky::jose::jws::JwsAlg; +use picky::jose::jwt::JwtSig; +use picky::key::PrivateKey; +use saphir::controller::Controller; +use saphir::http::{Method, StatusCode}; +use saphir::macros::controller; +use saphir::prelude::Request; use serde::{Deserialize, Serialize}; use slog_scope::error; use sogar_core::AccessToken; diff --git a/devolutions-gateway/src/http/middlewares/sogar_auth.rs b/devolutions-gateway/src/http/middlewares/sogar_auth.rs index afb1beaf6..e1276a025 100644 --- a/devolutions-gateway/src/http/middlewares/sogar_auth.rs +++ b/devolutions-gateway/src/http/middlewares/sogar_auth.rs @@ -1,9 +1,10 @@ -use crate::{ - config::{Config, SogarPermission, SogarUser}, - http::middlewares::auth::{parse_auth_header, AuthHeaderType}, -}; +use crate::config::{Config, SogarPermission, SogarUser}; +use crate::http::middlewares::auth::{parse_auth_header, AuthHeaderType}; use picky::jose::jwt::{JwtSig, JwtValidator}; -use saphir::{http, http_context::State, prelude::*, response::Builder as ResponseBuilder}; +use saphir::http; +use saphir::http_context::State; +use saphir::prelude::*; +use saphir::response::Builder as ResponseBuilder; use slog_scope::error; use sogar_core::registry::{ BLOB_DOWNLOAD_ENDPOINT, BLOB_EXIST_ENDPOINT, BLOB_GET_LOCATION_ENDPOINT, BLOB_UPLOAD_ENDPOINT, diff --git a/devolutions-gateway/src/registry/mod.rs b/devolutions-gateway/src/registry/mod.rs index fb9b1e6e7..acdec3853 100644 --- a/devolutions-gateway/src/registry/mod.rs +++ b/devolutions-gateway/src/registry/mod.rs @@ -1,19 +1,14 @@ mod push_files; +use crate::config::Config; +use crate::http::http_server::{NAMESPACE, REGISTRY_NAME}; use crate::registry::push_files::{get_file_list_from_path, SogarData}; -use crate::{ - config::Config, - http::http_server::{NAMESPACE, REGISTRY_NAME}, -}; use slog_scope::{debug, error}; use sogar_core::{create_annotation_for_filename, parse_digest, read_file_data, registry, FileInfo, Layer}; -use std::{ - fs, - path::{Path, PathBuf}, - sync::Arc, - thread, - time::Duration, -}; +use std::path::{Path, PathBuf}; +use std::sync::Arc; +use std::time::Duration; +use std::{fs, thread}; use tempfile::NamedTempFile; pub struct Registry { @@ -57,12 +52,12 @@ impl Registry { } if let Some(true) = config.keep_files { - thread::spawn(move || { - if let Some(duration) = config.keep_time { + if let Some(duration) = config.keep_time { + thread::spawn(move || { thread::sleep(Duration::from_secs(duration as u64)); remove_files(files); - } - }); + }); + } } else { remove_files(files); } diff --git a/devolutions-gateway/src/registry/push_files.rs b/devolutions-gateway/src/registry/push_files.rs index d85f28f8c..4160f5c42 100644 --- a/devolutions-gateway/src/registry/push_files.rs +++ b/devolutions-gateway/src/registry/push_files.rs @@ -57,16 +57,14 @@ impl SogarData { let reference = format!("{}:{}", self.image_name, tag); let joined_path: &str = &file_paths.join(";"); self.invoke_command(joined_path, reference); - for filepath in file_paths { - if let Err(e) = fs::remove_file(filepath.as_str()) { - error!("Failed to delete file {} after push: {}", filepath, e); - } - } } fn invoke_command(&self, file_path: &str, reference: String) { if self.sogar_path.to_str().is_none() || !self.sogar_path.is_file() { - error!("Failed to retrieve path string or path is not a file."); + error!( + "Failed to retrieve path string or path is not a file: {}", + self.sogar_path.display() + ); return; } diff --git a/devolutions-gateway/src/utils/association.rs b/devolutions-gateway/src/utils/association.rs index 2de25f35f..ce28badb7 100644 --- a/devolutions-gateway/src/utils/association.rs +++ b/devolutions-gateway/src/utils/association.rs @@ -20,7 +20,7 @@ pub async fn remove_jet_association( } } if !association.is_connected() { - debug!("Association is removed!"); + debug!("Association {} is removed!", association_id); let removed = jet_associations.remove(&association_id).is_some(); return removed; } else {