chore: translate all Spanish comments and log messages to English
This commit is contained in:
+77
-77
@@ -2,98 +2,98 @@ use std::time::Duration;
|
||||
use std::path::PathBuf;
|
||||
use std::env;
|
||||
|
||||
/// Configuración de caché
|
||||
/// Cache configuration
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CacheConfig {
|
||||
/// TTL para entradas de archivos en caché (ms)
|
||||
/// TTL for file cache entries (ms)
|
||||
pub file_ttl_ms: u64,
|
||||
/// TTL para entradas de directorios en caché (ms)
|
||||
/// TTL for directory cache entries (ms)
|
||||
pub directory_ttl_ms: u64,
|
||||
/// Máximo número de entradas en caché
|
||||
/// Maximum number of cache entries
|
||||
pub max_entries: usize,
|
||||
}
|
||||
|
||||
impl Default for CacheConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
file_ttl_ms: 60_000, // 1 minuto
|
||||
directory_ttl_ms: 120_000, // 2 minutos
|
||||
max_entries: 10_000, // 10,000 entradas
|
||||
file_ttl_ms: 60_000, // 1 minute
|
||||
directory_ttl_ms: 120_000, // 2 minutes
|
||||
max_entries: 10_000, // 10,000 entries
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración de timeouts para diferentes operaciones
|
||||
/// Timeout configuration for different operations
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TimeoutConfig {
|
||||
/// Timeout para operaciones de archivo (ms)
|
||||
/// Timeout for file operations (ms)
|
||||
pub file_operation_ms: u64,
|
||||
/// Timeout para operaciones de directorio (ms)
|
||||
/// Timeout for directory operations (ms)
|
||||
pub dir_operation_ms: u64,
|
||||
/// Timeout para adquisición de locks (ms)
|
||||
/// Timeout for lock acquisition (ms)
|
||||
pub lock_acquisition_ms: u64,
|
||||
/// Timeout para operaciones de red (ms)
|
||||
/// Timeout for network operations (ms)
|
||||
pub network_operation_ms: u64,
|
||||
}
|
||||
|
||||
impl Default for TimeoutConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
file_operation_ms: 10000, // 10 segundos
|
||||
dir_operation_ms: 30000, // 30 segundos
|
||||
lock_acquisition_ms: 5000, // 5 segundos
|
||||
network_operation_ms: 15000, // 15 segundos
|
||||
file_operation_ms: 10000, // 10 seconds
|
||||
dir_operation_ms: 30000, // 30 seconds
|
||||
lock_acquisition_ms: 5000, // 5 seconds
|
||||
network_operation_ms: 15000, // 15 seconds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TimeoutConfig {
|
||||
/// Obtiene un Duration para operaciones de archivo
|
||||
/// Gets a Duration for file operations
|
||||
pub fn file_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.file_operation_ms)
|
||||
}
|
||||
|
||||
/// Obtiene un Duration para operaciones de escritura de archivo
|
||||
/// Gets a Duration for file write operations
|
||||
pub fn file_write_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.file_operation_ms)
|
||||
}
|
||||
|
||||
/// Obtiene un Duration para operaciones de lectura de archivo
|
||||
/// Gets a Duration for file read operations
|
||||
pub fn file_read_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.file_operation_ms)
|
||||
}
|
||||
|
||||
/// Obtiene un Duration para operaciones de eliminación de archivo
|
||||
/// Gets a Duration for file delete operations
|
||||
pub fn file_delete_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.file_operation_ms)
|
||||
}
|
||||
|
||||
/// Obtiene un Duration para operaciones de directorio
|
||||
/// Gets a Duration for directory operations
|
||||
pub fn dir_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.dir_operation_ms)
|
||||
}
|
||||
|
||||
/// Obtiene un Duration para adquisición de locks
|
||||
/// Gets a Duration for lock acquisition
|
||||
pub fn lock_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.lock_acquisition_ms)
|
||||
}
|
||||
|
||||
/// Obtiene un Duration para operaciones de red
|
||||
/// Gets a Duration for network operations
|
||||
pub fn network_timeout(&self) -> Duration {
|
||||
Duration::from_millis(self.network_operation_ms)
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración para manejo de recursos grandes
|
||||
/// Configuration for large resource handling
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ResourceConfig {
|
||||
/// Umbral en MB para considerar un archivo como grande
|
||||
/// Threshold in MB to consider a file as large
|
||||
pub large_file_threshold_mb: u64,
|
||||
/// Umbral de entradas para considerar un directorio como grande
|
||||
/// Entry threshold to consider a directory as large
|
||||
pub large_dir_threshold_entries: usize,
|
||||
/// Tamaño de chunk para procesamiento de archivos grandes (bytes)
|
||||
/// Chunk size for large file processing (bytes)
|
||||
pub chunk_size_bytes: usize,
|
||||
/// Límite de tamaño de archivo para cargar en memoria (MB)
|
||||
/// File size limit for loading into memory (MB)
|
||||
pub max_in_memory_file_size_mb: u64,
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ impl Default for ResourceConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
large_file_threshold_mb: 100, // 100 MB
|
||||
large_dir_threshold_entries: 1000, // 1000 entradas
|
||||
large_dir_threshold_entries: 1000, // 1000 entries
|
||||
chunk_size_bytes: 1024 * 1024, // 1 MB
|
||||
max_in_memory_file_size_mb: 50, // 50 MB
|
||||
}
|
||||
@@ -109,71 +109,71 @@ impl Default for ResourceConfig {
|
||||
}
|
||||
|
||||
impl ResourceConfig {
|
||||
/// Convierte un tamaño en bytes a MB
|
||||
/// Converts a size in bytes to MB
|
||||
pub fn bytes_to_mb(&self, bytes: u64) -> u64 {
|
||||
bytes / (1024 * 1024)
|
||||
}
|
||||
|
||||
/// Determina si un archivo es considerado grande
|
||||
/// Determines if a file is considered large
|
||||
pub fn is_large_file(&self, size_bytes: u64) -> bool {
|
||||
self.bytes_to_mb(size_bytes) >= self.large_file_threshold_mb
|
||||
}
|
||||
|
||||
/// Determina si un archivo es suficientemente grande para procesamiento paralelo
|
||||
/// Determines if a file is large enough for parallel processing
|
||||
pub fn needs_parallel_processing(&self, size_bytes: u64, config: &ConcurrencyConfig) -> bool {
|
||||
self.bytes_to_mb(size_bytes) >= config.min_size_for_parallel_chunks_mb
|
||||
}
|
||||
|
||||
/// Determina si un archivo puede cargarse completo en memoria
|
||||
/// Determines if a file can be fully loaded into memory
|
||||
pub fn can_load_in_memory(&self, size_bytes: u64) -> bool {
|
||||
self.bytes_to_mb(size_bytes) <= self.max_in_memory_file_size_mb
|
||||
}
|
||||
|
||||
/// Determina si un directorio es considerado grande
|
||||
/// Determines if a directory is considered large
|
||||
pub fn is_large_directory(&self, entry_count: usize) -> bool {
|
||||
entry_count >= self.large_dir_threshold_entries
|
||||
}
|
||||
|
||||
/// Calcula el número de chunks para procesamiento paralelo
|
||||
/// Calculates the number of chunks for parallel processing
|
||||
pub fn calculate_optimal_chunks(&self, size_bytes: u64, config: &ConcurrencyConfig) -> usize {
|
||||
// Si el archivo no es suficientemente grande, retornar 1
|
||||
// If the file is not large enough, return 1
|
||||
if !self.needs_parallel_processing(size_bytes, config) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Calcular el número de chunks basado en el tamaño
|
||||
// Calculate the number of chunks based on size
|
||||
let chunk_count = (size_bytes as usize + config.parallel_chunk_size_bytes - 1)
|
||||
/ config.parallel_chunk_size_bytes;
|
||||
|
||||
// Limitar al máximo de chunks en paralelo
|
||||
// Limit to the maximum number of parallel chunks
|
||||
chunk_count.min(config.max_parallel_chunks)
|
||||
}
|
||||
|
||||
/// Calcula el tamaño óptimo de cada chunk para procesamiento paralelo
|
||||
/// Calculates the optimal size of each chunk for parallel processing
|
||||
pub fn calculate_chunk_size(&self, file_size: u64, chunk_count: usize) -> usize {
|
||||
if chunk_count <= 1 {
|
||||
return file_size as usize;
|
||||
}
|
||||
|
||||
// Distribuir equitativamente el tamaño entre los chunks
|
||||
// Distribute the size evenly among the chunks
|
||||
((file_size as usize) + chunk_count - 1) / chunk_count
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración para operaciones concurrentes
|
||||
/// Configuration for concurrent operations
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ConcurrencyConfig {
|
||||
/// Máximo de tareas de archivo concurrentes
|
||||
/// Maximum concurrent file tasks
|
||||
pub max_concurrent_files: usize,
|
||||
/// Máximo de tareas de directorio concurrentes
|
||||
/// Maximum concurrent directory tasks
|
||||
pub max_concurrent_dirs: usize,
|
||||
/// Máximo de operaciones de IO concurrentes
|
||||
/// Maximum concurrent IO operations
|
||||
pub max_concurrent_io: usize,
|
||||
/// Máximo de chunks para procesar en paralelo por archivo
|
||||
/// Maximum chunks to process in parallel per file
|
||||
pub max_parallel_chunks: usize,
|
||||
/// Tamaño mínimo de archivo (MB) para aplicar procesamiento paralelo de chunks
|
||||
/// Minimum file size (MB) to apply parallel chunk processing
|
||||
pub min_size_for_parallel_chunks_mb: u64,
|
||||
/// Tamaño de chunk para procesamiento paralelo (bytes)
|
||||
/// Chunk size for parallel processing (bytes)
|
||||
pub parallel_chunk_size_bytes: usize,
|
||||
}
|
||||
|
||||
@@ -190,16 +190,16 @@ impl Default for ConcurrencyConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración de almacenamiento
|
||||
/// Storage configuration
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StorageConfig {
|
||||
/// Directorio raíz para el almacenamiento
|
||||
/// Root directory for storage
|
||||
pub root_dir: String,
|
||||
/// Tamaño de chunk para procesamiento de archivos
|
||||
/// Chunk size for file processing
|
||||
pub chunk_size: usize,
|
||||
/// Umbral para procesamiento paralelo
|
||||
/// Threshold for parallel processing
|
||||
pub parallel_threshold: usize,
|
||||
/// Días de retención para archivos en la papelera
|
||||
/// Retention days for files in the trash
|
||||
pub trash_retention_days: u32,
|
||||
}
|
||||
|
||||
@@ -209,12 +209,12 @@ impl Default for StorageConfig {
|
||||
root_dir: "storage".to_string(),
|
||||
chunk_size: 1024 * 1024, // 1 MB
|
||||
parallel_threshold: 100 * 1024 * 1024, // 100 MB
|
||||
trash_retention_days: 30, // 30 días
|
||||
trash_retention_days: 30, // 30 days
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración de base de datos
|
||||
/// Database configuration
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DatabaseConfig {
|
||||
pub connection_string: String,
|
||||
@@ -239,7 +239,7 @@ impl Default for DatabaseConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración de autenticación
|
||||
/// Authentication configuration
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AuthConfig {
|
||||
pub jwt_secret: String,
|
||||
@@ -256,15 +256,15 @@ impl Default for AuthConfig {
|
||||
// to set OXICLOUD_JWT_SECRET in production. The from_env() method
|
||||
// will validate this and warn/panic if not configured.
|
||||
jwt_secret: String::new(),
|
||||
access_token_expiry_secs: 3600, // 1 hora
|
||||
refresh_token_expiry_secs: 2592000, // 30 días
|
||||
access_token_expiry_secs: 3600, // 1 hour
|
||||
refresh_token_expiry_secs: 2592000, // 30 days
|
||||
hash_memory_cost: 65536, // 64MB
|
||||
hash_time_cost: 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración de OpenID Connect (OIDC)
|
||||
/// OpenID Connect (OIDC) configuration
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OidcConfig {
|
||||
/// Whether OIDC authentication is enabled
|
||||
@@ -335,7 +335,7 @@ impl OidcConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración de funcionalidades (feature flags)
|
||||
/// Feature configuration (feature flags)
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FeaturesConfig {
|
||||
pub enable_auth: bool,
|
||||
@@ -357,34 +357,34 @@ impl Default for FeaturesConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuración global de la aplicación
|
||||
/// Global application configuration
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AppConfig {
|
||||
/// Ruta del directorio de almacenamiento
|
||||
/// Storage directory path
|
||||
pub storage_path: PathBuf,
|
||||
/// Ruta del directorio de archivos estáticos
|
||||
/// Static files directory path
|
||||
pub static_path: PathBuf,
|
||||
/// Puerto del servidor
|
||||
/// Server port
|
||||
pub server_port: u16,
|
||||
/// Host del servidor
|
||||
/// Server host
|
||||
pub server_host: String,
|
||||
/// Configuración de caché
|
||||
/// Cache configuration
|
||||
pub cache: CacheConfig,
|
||||
/// Configuración de timeouts
|
||||
/// Timeout configuration
|
||||
pub timeouts: TimeoutConfig,
|
||||
/// Configuración de recursos
|
||||
/// Resource configuration
|
||||
pub resources: ResourceConfig,
|
||||
/// Configuración de concurrencia
|
||||
/// Concurrency configuration
|
||||
pub concurrency: ConcurrencyConfig,
|
||||
/// Configuración de almacenamiento
|
||||
/// Storage configuration
|
||||
pub storage: StorageConfig,
|
||||
/// Configuración de base de datos
|
||||
/// Database configuration
|
||||
pub database: DatabaseConfig,
|
||||
/// Configuración de autenticación
|
||||
/// Authentication configuration
|
||||
pub auth: AuthConfig,
|
||||
/// Configuración de funcionalidades
|
||||
/// Feature configuration
|
||||
pub features: FeaturesConfig,
|
||||
/// Configuración OIDC
|
||||
/// OIDC configuration
|
||||
pub oidc: OidcConfig,
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ impl AppConfig {
|
||||
pub fn from_env() -> Self {
|
||||
let mut config = Self::default();
|
||||
|
||||
// Usar variables de entorno para sobrescribir valores por defecto
|
||||
// Use environment variables to override default values
|
||||
if let Ok(storage_path) = env::var("OXICLOUD_STORAGE_PATH") {
|
||||
config.storage_path = PathBuf::from(storage_path);
|
||||
}
|
||||
@@ -431,7 +431,7 @@ impl AppConfig {
|
||||
config.server_host = server_host;
|
||||
}
|
||||
|
||||
// Configuración de Database
|
||||
// Database configuration
|
||||
if let Ok(connection_string) = env::var("OXICLOUD_DB_CONNECTION_STRING") {
|
||||
config.database.connection_string = connection_string;
|
||||
}
|
||||
@@ -450,7 +450,7 @@ impl AppConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Configuración Auth
|
||||
// Auth configuration
|
||||
if let Ok(jwt_secret) = env::var("OXICLOUD_JWT_SECRET") {
|
||||
config.auth.jwt_secret = jwt_secret;
|
||||
}
|
||||
@@ -582,7 +582,7 @@ impl AppConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Obtenemos una configuración global por defecto
|
||||
/// Gets a default global configuration
|
||||
pub fn default_config() -> AppConfig {
|
||||
AppConfig::default()
|
||||
}
|
||||
+53
-53
@@ -53,10 +53,10 @@ use crate::common::stubs::{
|
||||
StubSearchUseCase,
|
||||
};
|
||||
|
||||
/// Fábrica para los diferentes componentes de la aplicación
|
||||
/// Factory for the different application components
|
||||
///
|
||||
/// Esta fábrica centraliza la creación de todos los servicios de la aplicación,
|
||||
/// garantizando el orden correcto de inicialización y resolviendo dependencias circulares.
|
||||
/// This factory centralizes the creation of all application services,
|
||||
/// ensuring the correct initialization order and resolving circular dependencies.
|
||||
pub struct AppServiceFactory {
|
||||
storage_path: PathBuf,
|
||||
locales_path: PathBuf,
|
||||
@@ -64,7 +64,7 @@ pub struct AppServiceFactory {
|
||||
}
|
||||
|
||||
impl AppServiceFactory {
|
||||
/// Crea una nueva fábrica de servicios
|
||||
/// Creates a new service factory
|
||||
pub fn new(storage_path: PathBuf, locales_path: PathBuf) -> Self {
|
||||
Self {
|
||||
storage_path,
|
||||
@@ -73,7 +73,7 @@ impl AppServiceFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/// Crea una nueva fábrica de servicios con configuración personalizada
|
||||
/// Creates a new service factory with custom configuration
|
||||
pub fn with_config(storage_path: PathBuf, locales_path: PathBuf, config: AppConfig) -> Self {
|
||||
Self {
|
||||
storage_path,
|
||||
@@ -82,17 +82,17 @@ impl AppServiceFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/// Obtiene la configuración
|
||||
/// Gets the configuration
|
||||
pub fn config(&self) -> &AppConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
/// Obtiene la ruta de almacenamiento
|
||||
/// Gets the storage path
|
||||
pub fn storage_path(&self) -> &PathBuf {
|
||||
&self.storage_path
|
||||
}
|
||||
|
||||
/// Inicializa los servicios base del sistema
|
||||
/// Initializes the core system services
|
||||
pub async fn create_core_services(&self) -> Result<CoreServices, DomainError> {
|
||||
// Path service
|
||||
let path_service = Arc::new(PathService::new(self.storage_path.clone()));
|
||||
@@ -105,57 +105,57 @@ impl AppServiceFactory {
|
||||
}));
|
||||
tracing::info!("FileContentCache initialized: max 10MB/file, 512MB total, 10k entries");
|
||||
|
||||
// ID mapping service para carpetas
|
||||
// ID mapping service for folders
|
||||
let folder_id_mapping_path = self.storage_path.join("folder_ids.json");
|
||||
let folder_id_mapping_service = Arc::new(
|
||||
IdMappingService::new(folder_id_mapping_path).await?
|
||||
);
|
||||
|
||||
// ID mapping service para archivos
|
||||
// ID mapping service for files
|
||||
let file_id_mapping_path = self.storage_path.join("file_ids.json");
|
||||
let file_id_mapping_service = Arc::new(
|
||||
IdMappingService::new(file_id_mapping_path).await?
|
||||
);
|
||||
|
||||
// Optimizer con batch processing y caching
|
||||
// Optimizer with batch processing and caching
|
||||
let id_mapping_optimizer = Arc::new(
|
||||
IdMappingOptimizer::new(folder_id_mapping_service.clone())
|
||||
);
|
||||
|
||||
// Iniciar tarea de limpieza del optimizer
|
||||
// Start optimizer cleanup task
|
||||
IdMappingOptimizer::start_cleanup_task(id_mapping_optimizer.clone());
|
||||
|
||||
// Thumbnail service para generación de miniaturas
|
||||
// Thumbnail service for thumbnail generation
|
||||
let thumbnail_service = Arc::new(
|
||||
crate::infrastructure::services::thumbnail_service::ThumbnailService::new(
|
||||
&self.storage_path,
|
||||
5000, // max 5000 thumbnails en cache
|
||||
100 * 1024 * 1024, // max 100MB de cache
|
||||
5000, // max 5000 thumbnails in cache
|
||||
100 * 1024 * 1024, // max 100MB cache
|
||||
)
|
||||
);
|
||||
// Inicializar directorios de thumbnails
|
||||
// Initialize thumbnail directories
|
||||
thumbnail_service.initialize().await?;
|
||||
|
||||
// Write-behind cache para uploads instantáneos de archivos pequeños
|
||||
// Write-behind cache for instant uploads of small files
|
||||
let write_behind_cache = crate::infrastructure::services::write_behind_cache::WriteBehindCache::new();
|
||||
|
||||
// Chunked upload service para archivos grandes (>10MB)
|
||||
// Chunked upload service for large files (>10MB)
|
||||
let chunked_temp_dir = std::path::PathBuf::from(&self.storage_path).join(".uploads");
|
||||
let chunked_upload_service = Arc::new(
|
||||
crate::infrastructure::services::chunked_upload_service::ChunkedUploadService::new(chunked_temp_dir)
|
||||
);
|
||||
|
||||
// Image transcoding service para conversión automática a WebP
|
||||
// Image transcoding service for automatic WebP conversion
|
||||
let image_transcode_service = Arc::new(
|
||||
crate::infrastructure::services::image_transcode_service::ImageTranscodeService::new(
|
||||
&self.storage_path,
|
||||
2000, // max 2000 imágenes transcodificadas en cache
|
||||
50 * 1024 * 1024, // max 50MB de cache en memoria
|
||||
2000, // max 2000 transcoded images in cache
|
||||
50 * 1024 * 1024, // max 50MB in-memory cache
|
||||
)
|
||||
);
|
||||
image_transcode_service.initialize().await?;
|
||||
|
||||
// Deduplication service para eliminar archivos duplicados
|
||||
// Deduplication service for removing duplicate files
|
||||
let dedup_service = Arc::new(
|
||||
crate::infrastructure::services::dedup_service::DedupService::new(&self.storage_path)
|
||||
);
|
||||
@@ -189,7 +189,7 @@ impl AppServiceFactory {
|
||||
})
|
||||
}
|
||||
|
||||
/// Inicializa los servicios de repositorio
|
||||
/// Initializes the repository services
|
||||
pub fn create_repository_services(&self, core: &CoreServices) -> RepositoryServices {
|
||||
// Storage mediator - uses stub initially, will be replaced after folder repo is ready
|
||||
let storage_mediator_stub: Arc<dyn StorageMediator> = Arc::new(
|
||||
@@ -216,13 +216,13 @@ impl AppServiceFactory {
|
||||
FileMetadataCache::default_with_config(core.config.clone())
|
||||
);
|
||||
|
||||
// Iniciar tarea de limpieza de metadata cache
|
||||
// Start metadata cache cleanup task
|
||||
let cache_clone = metadata_cache.clone();
|
||||
tokio::spawn(async move {
|
||||
FileMetadataCache::start_cleanup_task(cache_clone).await;
|
||||
});
|
||||
|
||||
// Buffer pool para optimización de memoria
|
||||
// Buffer pool for memory optimization
|
||||
let buffer_pool = BufferPool::new(256 * 1024, 50, 120); // 256KB buffers, 50 max, 2 min TTL
|
||||
BufferPool::start_cleaner(buffer_pool.clone());
|
||||
|
||||
@@ -232,7 +232,7 @@ impl AppServiceFactory {
|
||||
buffer_pool.clone()
|
||||
));
|
||||
|
||||
// File repositories separados para lectura y escritura
|
||||
// Separate file repositories for reading and writing
|
||||
let file_read_repository = Arc::new(FileFsReadRepository::new(
|
||||
self.storage_path.clone(),
|
||||
storage_mediator.clone(),
|
||||
@@ -281,19 +281,19 @@ impl AppServiceFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/// Inicializa los servicios de aplicación
|
||||
/// Initializes the application services
|
||||
pub fn create_application_services(
|
||||
&self,
|
||||
core: &CoreServices,
|
||||
repos: &RepositoryServices,
|
||||
trash_service: Option<Arc<dyn TrashUseCase>>,
|
||||
) -> ApplicationServices {
|
||||
// Servicios principales
|
||||
// Main services
|
||||
let folder_service = Arc::new(FolderService::new(
|
||||
repos.folder_repository.clone()
|
||||
));
|
||||
|
||||
// Servicios refactorizados con todos los puertos de infraestructura
|
||||
// Refactored services with all infrastructure ports
|
||||
let file_upload_service = Arc::new(FileUploadService::new_full(
|
||||
repos.file_write_repository.clone(),
|
||||
repos.file_read_repository.clone(),
|
||||
@@ -308,7 +308,7 @@ impl AppServiceFactory {
|
||||
core.image_transcode_service.clone(),
|
||||
));
|
||||
|
||||
// FileManagementService con dedup y trash
|
||||
// FileManagementService with dedup and trash
|
||||
let file_management_service = Arc::new(FileManagementService::new_full(
|
||||
repos.file_write_repository.clone(),
|
||||
repos.file_read_repository.clone(),
|
||||
@@ -325,7 +325,7 @@ impl AppServiceFactory {
|
||||
repos.i18n_repository.clone()
|
||||
));
|
||||
|
||||
// Search service con caché
|
||||
// Search service with cache
|
||||
let search_service: Option<Arc<dyn SearchUseCase>> = Some(Arc::new(SearchService::new(
|
||||
repos.file_read_repository.clone(),
|
||||
repos.folder_repository.clone(),
|
||||
@@ -336,9 +336,9 @@ impl AppServiceFactory {
|
||||
tracing::info!("Application services initialized");
|
||||
|
||||
ApplicationServices {
|
||||
// Tipos concretos para handlers que los necesitan
|
||||
// Concrete types for handlers that need them
|
||||
folder_service_concrete: folder_service.clone(),
|
||||
// Traits para abstracción
|
||||
// Traits for abstraction
|
||||
folder_service,
|
||||
file_upload_service,
|
||||
file_retrieval_service,
|
||||
@@ -347,13 +347,13 @@ impl AppServiceFactory {
|
||||
i18n_service,
|
||||
trash_service, // Already set via parameter
|
||||
search_service,
|
||||
share_service: None, // Se configura después con create_share_service
|
||||
favorites_service: None, // Se configura después con create_favorites_service
|
||||
recent_service: None, // Se configura después con create_recent_service
|
||||
share_service: None, // Configured later with create_share_service
|
||||
favorites_service: None, // Configured later with create_favorites_service
|
||||
recent_service: None, // Configured later with create_recent_service
|
||||
}
|
||||
}
|
||||
|
||||
/// Crea el servicio de papelera
|
||||
/// Creates the trash service
|
||||
pub async fn create_trash_service(
|
||||
&self,
|
||||
repos: &RepositoryServices,
|
||||
@@ -374,7 +374,7 @@ impl AppServiceFactory {
|
||||
self.config.storage.trash_retention_days,
|
||||
));
|
||||
|
||||
// Inicializar servicio de limpieza
|
||||
// Initialize cleanup service
|
||||
let cleanup_service = TrashCleanupService::new(
|
||||
service.clone(),
|
||||
trash_repo.clone(),
|
||||
@@ -387,7 +387,7 @@ impl AppServiceFactory {
|
||||
Some(service as Arc<dyn TrashUseCase>)
|
||||
}
|
||||
|
||||
/// Crea el servicio de compartición
|
||||
/// Creates the sharing service
|
||||
pub fn create_share_service(
|
||||
&self,
|
||||
repos: &RepositoryServices,
|
||||
@@ -417,7 +417,7 @@ impl AppServiceFactory {
|
||||
Some(service)
|
||||
}
|
||||
|
||||
/// Crea el servicio de favoritos (requiere base de datos)
|
||||
/// Creates the favorites service (requires database)
|
||||
pub fn create_favorites_service(
|
||||
&self,
|
||||
db_pool: &Arc<PgPool>,
|
||||
@@ -430,7 +430,7 @@ impl AppServiceFactory {
|
||||
service
|
||||
}
|
||||
|
||||
/// Crea el servicio de elementos recientes (requiere base de datos)
|
||||
/// Creates the recent items service (requires database)
|
||||
pub fn create_recent_service(
|
||||
&self,
|
||||
db_pool: &Arc<PgPool>,
|
||||
@@ -446,7 +446,7 @@ impl AppServiceFactory {
|
||||
service
|
||||
}
|
||||
|
||||
/// Precarga traducciones
|
||||
/// Preloads translations
|
||||
pub async fn preload_translations(&self, i18n_service: &I18nApplicationService) {
|
||||
use crate::domain::services::i18n_service::Locale;
|
||||
|
||||
@@ -468,7 +468,7 @@ impl AppServiceFactory {
|
||||
tracing::info!("Translations preloaded");
|
||||
}
|
||||
|
||||
/// Precarga directorios en caché
|
||||
/// Preloads directories into cache
|
||||
pub async fn preload_cache(&self, metadata_cache: &FileMetadataCache) {
|
||||
tracing::info!("Preloading common directories to warm up cache...");
|
||||
if let Ok(count) = metadata_cache.preload_directory(&self.storage_path, true, 1).await {
|
||||
@@ -476,7 +476,7 @@ impl AppServiceFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/// Crea el servicio de uso de almacenamiento (requiere base de datos)
|
||||
/// Creates the storage usage service (requires database)
|
||||
pub fn create_storage_usage_service(
|
||||
&self,
|
||||
repos: &RepositoryServices,
|
||||
@@ -495,9 +495,9 @@ impl AppServiceFactory {
|
||||
service
|
||||
}
|
||||
|
||||
/// Construye el AppState completo usando todos los servicios de la fábrica.
|
||||
/// Builds the complete AppState using all factory services.
|
||||
///
|
||||
/// Este es el punto de entrada principal que reemplaza toda la lógica manual de `main.rs`.
|
||||
/// This is the main entry point that replaces all manual logic in `main.rs`.
|
||||
pub async fn build_app_state(
|
||||
&self,
|
||||
db_pool: Option<Arc<PgPool>>,
|
||||
@@ -677,7 +677,7 @@ impl AppServiceFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/// Contenedor para servicios base
|
||||
/// Container for core services
|
||||
#[derive(Clone)]
|
||||
pub struct CoreServices {
|
||||
pub path_service: Arc<PathService>,
|
||||
@@ -695,7 +695,7 @@ pub struct CoreServices {
|
||||
pub config: AppConfig,
|
||||
}
|
||||
|
||||
/// Contenedor para servicios de repositorio
|
||||
/// Container for repository services
|
||||
#[derive(Clone)]
|
||||
pub struct RepositoryServices {
|
||||
pub folder_repository: Arc<dyn FolderStoragePort>,
|
||||
@@ -707,12 +707,12 @@ pub struct RepositoryServices {
|
||||
pub trash_repository: Option<Arc<dyn crate::domain::repositories::trash_repository::TrashRepository>>,
|
||||
}
|
||||
|
||||
/// Contenedor para servicios de aplicación
|
||||
/// Container for application services
|
||||
#[derive(Clone)]
|
||||
pub struct ApplicationServices {
|
||||
// Tipos concretos para compatibilidad con handlers existentes
|
||||
// Concrete types for compatibility with existing handlers
|
||||
pub folder_service_concrete: Arc<FolderService>,
|
||||
// Traits para abstracción
|
||||
// Traits for abstraction
|
||||
pub folder_service: Arc<dyn FolderUseCase>,
|
||||
pub file_upload_service: Arc<dyn FileUploadUseCase>,
|
||||
pub file_retrieval_service: Arc<dyn FileRetrievalUseCase>,
|
||||
@@ -726,14 +726,14 @@ pub struct ApplicationServices {
|
||||
pub recent_service: Option<Arc<dyn RecentItemsUseCase>>,
|
||||
}
|
||||
|
||||
/// Contenedor para servicios de autenticación
|
||||
/// Container for authentication services
|
||||
#[derive(Clone)]
|
||||
pub struct AuthServices {
|
||||
pub token_service: Arc<dyn crate::application::ports::auth_ports::TokenServicePort>,
|
||||
pub auth_application_service: Arc<AuthApplicationService>,
|
||||
}
|
||||
|
||||
/// Estado global de la aplicación para dependency injection
|
||||
/// Global application state for dependency injection
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub core: CoreServices,
|
||||
|
||||
+14
-14
@@ -1,21 +1,21 @@
|
||||
//! Errores de la aplicación
|
||||
//! Application errors
|
||||
//!
|
||||
//! Este módulo re-exporta los errores del dominio para compatibilidad.
|
||||
//! Las conversiones de errores de infraestructura (sqlx, serde_json, etc.)
|
||||
//! se encuentran en infrastructure/adapters/error_adapters.rs, siguiendo
|
||||
//! los principios de Clean Architecture donde el dominio no debe conocer
|
||||
//! detalles de infraestructura.
|
||||
//! This module re-exports domain errors for compatibility.
|
||||
//! Infrastructure error conversions (sqlx, serde_json, etc.)
|
||||
//! are located in infrastructure/adapters/error_adapters.rs, following
|
||||
//! Clean Architecture principles where the domain should not know about
|
||||
//! infrastructure details.
|
||||
|
||||
// Re-exportar errores del dominio para compatibilidad
|
||||
// Re-export domain errors for compatibility
|
||||
pub use crate::domain::errors::{DomainError, ErrorKind, Result};
|
||||
|
||||
// Re-exportar AppError desde interfaces para compatibilidad hacia atrás
|
||||
// NOTA: El lugar canónico de AppError es ahora crate::interfaces::errors
|
||||
// Re-export AppError from interfaces for backward compatibility
|
||||
// NOTE: The canonical location of AppError is now crate::interfaces::errors
|
||||
|
||||
// Las conversiones de errores de infraestructura se han movido a:
|
||||
// Infrastructure error conversions have been moved to:
|
||||
// crate::infrastructure::adapters::error_adapters
|
||||
//
|
||||
// Para convertir errores de infraestructura a DomainError, use:
|
||||
// - El trait IntoDomainError para conversiones explícitas con contexto
|
||||
// - O maneje los errores en los repositorios/servicios de infraestructura
|
||||
// usando map_err() con DomainError::internal_error() o métodos similares
|
||||
// To convert infrastructure errors to DomainError, use:
|
||||
// - The IntoDomainError trait for explicit conversions with context
|
||||
// - Or handle errors in infrastructure repositories/services
|
||||
// using map_err() with DomainError::internal_error() or similar methods
|
||||
|
||||
Reference in New Issue
Block a user