style: apply rustfmt formatting to fix CI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -371,11 +371,7 @@ impl ChunkedUploadService {
|
||||
|
||||
/// Verify that the given session belongs to the given user.
|
||||
/// Returns 404 (not 403) to avoid revealing the existence of other users' sessions.
|
||||
fn verify_session_owner(
|
||||
&self,
|
||||
upload_id: &str,
|
||||
user_id: &str,
|
||||
) -> Result<(), String> {
|
||||
fn verify_session_owner(&self, upload_id: &str, user_id: &str) -> Result<(), String> {
|
||||
let session = self
|
||||
.sessions
|
||||
.get(upload_id)
|
||||
@@ -592,7 +588,11 @@ impl ChunkedUploadService {
|
||||
}
|
||||
|
||||
/// Get upload status
|
||||
async fn get_status_inner(&self, upload_id: &str, user_id: &str) -> Result<UploadStatusResponseDto, String> {
|
||||
async fn get_status_inner(
|
||||
&self,
|
||||
upload_id: &str,
|
||||
user_id: &str,
|
||||
) -> Result<UploadStatusResponseDto, String> {
|
||||
self.verify_session_owner(upload_id, user_id)?;
|
||||
|
||||
let session = self
|
||||
@@ -808,9 +808,16 @@ impl ChunkedUploadPort for ChunkedUploadService {
|
||||
total_size: u64,
|
||||
chunk_size: Option<usize>,
|
||||
) -> Result<CreateUploadResponseDto, DomainError> {
|
||||
self.create_session_inner(user_id.to_owned(), filename, folder_id, content_type, total_size, chunk_size)
|
||||
.await
|
||||
.map_err(|e| DomainError::new(ErrorKind::InternalError, "ChunkedUpload", e))
|
||||
self.create_session_inner(
|
||||
user_id.to_owned(),
|
||||
filename,
|
||||
folder_id,
|
||||
content_type,
|
||||
total_size,
|
||||
chunk_size,
|
||||
)
|
||||
.await
|
||||
.map_err(|e| DomainError::new(ErrorKind::InternalError, "ChunkedUpload", e))
|
||||
}
|
||||
|
||||
async fn upload_chunk(
|
||||
@@ -826,7 +833,11 @@ impl ChunkedUploadPort for ChunkedUploadService {
|
||||
.map_err(|e| DomainError::new(ErrorKind::InternalError, "ChunkedUpload", e))
|
||||
}
|
||||
|
||||
async fn get_status(&self, upload_id: &str, user_id: &str) -> Result<UploadStatusResponseDto, DomainError> {
|
||||
async fn get_status(
|
||||
&self,
|
||||
upload_id: &str,
|
||||
user_id: &str,
|
||||
) -> Result<UploadStatusResponseDto, DomainError> {
|
||||
self.get_status_inner(upload_id, user_id)
|
||||
.await
|
||||
.map_err(|e| DomainError::new(ErrorKind::NotFound, "ChunkedUpload", e))
|
||||
@@ -1097,14 +1108,19 @@ mod tests {
|
||||
assert_eq!(r1.bytes_received, 1024);
|
||||
|
||||
// 3. Status check
|
||||
let status = service.get_status_inner(&id, "test-user").await.expect("status");
|
||||
let status = service
|
||||
.get_status_inner(&id, "test-user")
|
||||
.await
|
||||
.expect("status");
|
||||
assert!(status.is_complete);
|
||||
assert_eq!(status.completed_chunks, 2);
|
||||
assert!(status.pending_chunks.is_empty());
|
||||
|
||||
// 4. Complete (assemble)
|
||||
let (path, filename, _folder, _ct, size, hash) =
|
||||
service.complete_upload_inner(&id, "test-user").await.expect("complete");
|
||||
let (path, filename, _folder, _ct, size, hash) = service
|
||||
.complete_upload_inner(&id, "test-user")
|
||||
.await
|
||||
.expect("complete");
|
||||
assert_eq!(filename, "test.txt");
|
||||
assert_eq!(size, 1024);
|
||||
assert!(!hash.is_empty());
|
||||
@@ -1116,7 +1132,10 @@ mod tests {
|
||||
assert_eq!(&content[512..], &[b'B'; 512]);
|
||||
|
||||
// 6. Finalize
|
||||
service.finalize_upload_inner(&id, "test-user").await.expect("finalize");
|
||||
service
|
||||
.finalize_upload_inner(&id, "test-user")
|
||||
.await
|
||||
.expect("finalize");
|
||||
assert_eq!(service.active_sessions().await, 0);
|
||||
|
||||
let _ = fs::remove_dir_all(&base).await;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio::fs;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::domain::services::i18n_service::{I18nError, I18nResult, I18nService, Locale};
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
//! Compatible with Authentik, Keycloak, and any standard OIDC provider.
|
||||
|
||||
use serde::Deserialize;
|
||||
use tokio::sync::RwLock;
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::application::ports::auth_ports::{OidcIdClaims, OidcServicePort, OidcTokenSet};
|
||||
use crate::common::config::OidcConfig;
|
||||
|
||||
@@ -119,10 +119,10 @@ impl PathResolverService {
|
||||
LIMIT 1
|
||||
"#,
|
||||
)
|
||||
.bind(path) // $1
|
||||
.bind(filename) // $2
|
||||
.bind(&folder_path) // $3
|
||||
.bind(user_id) // $4
|
||||
.bind(path) // $1
|
||||
.bind(filename) // $2
|
||||
.bind(&folder_path) // $3
|
||||
.bind(user_id) // $4
|
||||
.fetch_optional(self.pool.as_ref())
|
||||
.await
|
||||
.map_err(|e| DomainError::internal_error("PathResolver", format!("resolve_for_user: {e}")))?
|
||||
@@ -215,7 +215,9 @@ impl PathResolverService {
|
||||
.bind(user_id)
|
||||
.fetch_one(self.pool.as_ref())
|
||||
.await
|
||||
.map_err(|e| DomainError::internal_error("PathResolver", format!("exists_for_user: {e}")))?;
|
||||
.map_err(|e| {
|
||||
DomainError::internal_error("PathResolver", format!("exists_for_user: {e}"))
|
||||
})?;
|
||||
|
||||
Ok(exists)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,8 @@ fn tiny_png() -> Vec<u8> {
|
||||
let mut img = image::RgbaImage::new(1, 1);
|
||||
img.put_pixel(0, 0, image::Rgba([255, 0, 0, 255]));
|
||||
let mut buf = Vec::new();
|
||||
img.write_to(
|
||||
&mut std::io::Cursor::new(&mut buf),
|
||||
image::ImageFormat::Png,
|
||||
)
|
||||
.expect("encode test PNG");
|
||||
img.write_to(&mut std::io::Cursor::new(&mut buf), image::ImageFormat::Png)
|
||||
.expect("encode test PNG");
|
||||
buf
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user