perf: Phase 4+5 optimizations — uploads 10x, downloads 2x, concurrent 2x. moka cache, 512KB buffers, remove sync_all, hash-on-write, preloaded queries, bench.sh v3, gitignore storage/. 500MB upload 12.6s->1.3s (392MB/s). RSS 69-113MB, 0 swap.
This commit is contained in:
@@ -79,6 +79,7 @@ impl CalendarEvent {
|
||||
* @param ical_data Complete iCalendar data (VEVENT component)
|
||||
* @return Result containing the new CalendarEvent or a domain error
|
||||
*/
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
calendar_id: Uuid,
|
||||
summary: String,
|
||||
@@ -165,6 +166,7 @@ impl CalendarEvent {
|
||||
* @param updated_at Time when the event was last modified
|
||||
* @return Result containing the new CalendarEvent or a domain error
|
||||
*/
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn with_id(
|
||||
id: Uuid,
|
||||
calendar_id: Uuid,
|
||||
|
||||
@@ -35,7 +35,7 @@ impl AddressBook {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reconstructs from persistence (no validation)
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from_raw(
|
||||
id: Uuid,
|
||||
name: String,
|
||||
|
||||
@@ -127,7 +127,7 @@ impl File {
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a file with specific timestamps (for reconstruction)
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn with_timestamps(
|
||||
id: String,
|
||||
name: String,
|
||||
@@ -196,8 +196,7 @@ impl File {
|
||||
self.modified_at
|
||||
}
|
||||
|
||||
/// Creates a new File instance from a DTO
|
||||
/// This function is primarily for conversions in batch handlers
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from_dto(
|
||||
id: String,
|
||||
name: String,
|
||||
|
||||
@@ -41,8 +41,7 @@ impl Session {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reconstruct a Session from persisted data (e.g. database row).
|
||||
/// Skips ID generation — uses the provided values directly.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from_raw(
|
||||
id: String,
|
||||
user_id: String,
|
||||
|
||||
@@ -84,8 +84,7 @@ impl Share {
|
||||
})
|
||||
}
|
||||
|
||||
/// Reconstruct a Share from persisted data (e.g. filesystem/database).
|
||||
/// Skips validation and ID generation — uses the provided values directly.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from_raw(
|
||||
id: String,
|
||||
item_id: String,
|
||||
|
||||
@@ -41,8 +41,7 @@ impl TrashedItem {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reconstruct a TrashedItem from persisted data (e.g. JSON index).
|
||||
/// Skips ID generation — uses the provided values directly.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from_raw(
|
||||
id: Uuid,
|
||||
original_id: Uuid,
|
||||
|
||||
@@ -128,7 +128,7 @@ impl User {
|
||||
})
|
||||
}
|
||||
|
||||
// Create from existing values (for reconstruction from DB)
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from_data(
|
||||
id: String,
|
||||
username: String,
|
||||
@@ -159,7 +159,7 @@ impl User {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reconstruct from DB with OIDC fields
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from_data_full(
|
||||
id: String,
|
||||
username: String,
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
//! the infrastructure layer.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::pin::Pin;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
@@ -81,13 +80,15 @@ pub trait FileWriteRepository: Send + Sync + 'static {
|
||||
content: Vec<u8>,
|
||||
) -> Result<File, DomainError>;
|
||||
|
||||
/// Streaming upload — writes chunks to disk without accumulating in RAM.
|
||||
async fn save_file_from_stream(
|
||||
/// Streaming upload — saves a file from a temp file already on disk.
|
||||
async fn save_file_from_temp(
|
||||
&self,
|
||||
name: String,
|
||||
folder_id: Option<String>,
|
||||
content_type: String,
|
||||
stream: Pin<Box<dyn Stream<Item = Result<Bytes, std::io::Error>> + Send>>,
|
||||
temp_path: &std::path::Path,
|
||||
size: u64,
|
||||
pre_computed_hash: Option<String>,
|
||||
) -> Result<File, DomainError>;
|
||||
|
||||
/// Moves a file to another folder.
|
||||
|
||||
@@ -18,8 +18,9 @@ pub enum I18nError {
|
||||
pub type I18nResult<T> = Result<T, I18nError>;
|
||||
|
||||
/// Supported locales
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||
pub enum Locale {
|
||||
#[default]
|
||||
English,
|
||||
Spanish,
|
||||
French,
|
||||
@@ -40,7 +41,7 @@ impl Locale {
|
||||
}
|
||||
|
||||
/// Create from locale code string
|
||||
pub fn from_str(code: &str) -> Option<Self> {
|
||||
pub fn from_code(code: &str) -> Option<Self> {
|
||||
match code.to_lowercase().as_str() {
|
||||
"en" => Some(Locale::English),
|
||||
"es" => Some(Locale::Spanish),
|
||||
@@ -50,11 +51,6 @@ impl Locale {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get default locale
|
||||
pub fn default() -> Self {
|
||||
Locale::English
|
||||
}
|
||||
}
|
||||
|
||||
/// Interface for i18n service (primary port)
|
||||
|
||||
@@ -78,15 +78,19 @@ impl StoragePath {
|
||||
self.segments.is_empty()
|
||||
}
|
||||
|
||||
/// Converts the path to a string with format "/segment1/segment2/..."
|
||||
pub fn to_string(&self) -> String {
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StoragePath {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if self.segments.is_empty() {
|
||||
"/".to_string()
|
||||
write!(f, "/")
|
||||
} else {
|
||||
format!("/{}", self.segments.join("/"))
|
||||
write!(f, "/{}", self.segments.join("/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StoragePath {
|
||||
/// Returns the path representation as a string
|
||||
pub fn as_str(&self) -> &str {
|
||||
// Note: The implementation should really store the string,
|
||||
|
||||
Reference in New Issue
Block a user