quick fix
This commit is contained in:
+11
-13
@@ -44,7 +44,7 @@ use crate::common::stubs::{
|
||||
StubFileReadPort, StubFileWritePort, StubFolderStoragePort,
|
||||
StubI18nService, StubFolderUseCase, StubFileUploadUseCase,
|
||||
StubFileRetrievalUseCase, StubFileManagementUseCase, StubFileUseCaseFactory,
|
||||
StubSearchUseCase,
|
||||
StubSearchUseCase, StubDedupPort,
|
||||
};
|
||||
|
||||
/// Factory for the different application components
|
||||
@@ -86,8 +86,10 @@ impl AppServiceFactory {
|
||||
&self.storage_path
|
||||
}
|
||||
|
||||
/// Initializes the core system services
|
||||
pub async fn create_core_services(&self) -> Result<CoreServices, DomainError> {
|
||||
/// Initializes the core system services.
|
||||
///
|
||||
/// Requires a `PgPool` because `DedupService` stores its index in PostgreSQL.
|
||||
pub async fn create_core_services(&self, db_pool: &Arc<PgPool>) -> Result<CoreServices, DomainError> {
|
||||
// Path service (still needed for blob storage root + thumbnails)
|
||||
let path_service = Arc::new(PathService::new(self.storage_path.clone()));
|
||||
|
||||
@@ -126,9 +128,9 @@ impl AppServiceFactory {
|
||||
);
|
||||
image_transcode_service.initialize().await?;
|
||||
|
||||
// Deduplication service — PRIMARY blob storage engine
|
||||
// Deduplication service — PRIMARY blob storage engine (PostgreSQL-backed index)
|
||||
let dedup_service = Arc::new(
|
||||
crate::infrastructure::services::dedup_service::DedupService::new(&self.storage_path)
|
||||
crate::infrastructure::services::dedup_service::DedupService::new(&self.storage_path, db_pool.clone())
|
||||
);
|
||||
dedup_service.initialize().await?;
|
||||
|
||||
@@ -416,8 +418,8 @@ impl AppServiceFactory {
|
||||
DomainError::internal_error("Database", "PostgreSQL database is required for blob storage model")
|
||||
})?;
|
||||
|
||||
// 1. Core services
|
||||
let core = self.create_core_services().await?;
|
||||
// 1. Core services (PgPool needed for DedupService index)
|
||||
let core = self.create_core_services(&pool).await?;
|
||||
|
||||
// 2. Repository services (requires PgPool for all metadata)
|
||||
let repos = self.create_repository_services(&core, &pool);
|
||||
@@ -705,12 +707,8 @@ impl Default for AppState {
|
||||
)
|
||||
);
|
||||
|
||||
// Create dummy dedup service
|
||||
let dummy_dedup_service: Arc<dyn DedupPort> = Arc::new(
|
||||
crate::infrastructure::services::dedup_service::DedupService::new(
|
||||
&std::path::PathBuf::from("./storage")
|
||||
)
|
||||
);
|
||||
// Stub dedup service (Default is only used for routing stubs, never for real I/O)
|
||||
let dummy_dedup_service: Arc<dyn DedupPort> = Arc::new(StubDedupPort);
|
||||
|
||||
// Core services using stubs
|
||||
let core_services = CoreServices {
|
||||
|
||||
@@ -533,6 +533,91 @@ impl SearchUseCase for StubSearchUseCase {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DedupPort
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
use crate::application::ports::dedup_ports::{
|
||||
BlobMetadataDto, DedupPort, DedupResultDto, DedupStatsDto,
|
||||
};
|
||||
|
||||
pub struct StubDedupPort;
|
||||
|
||||
#[async_trait]
|
||||
impl DedupPort for StubDedupPort {
|
||||
async fn store_bytes(
|
||||
&self,
|
||||
_content: &[u8],
|
||||
_content_type: Option<String>,
|
||||
) -> Result<DedupResultDto, DomainError> {
|
||||
Err(DomainError::internal_error(
|
||||
"DedupService",
|
||||
"DedupService not initialized",
|
||||
))
|
||||
}
|
||||
|
||||
async fn store_from_file(
|
||||
&self,
|
||||
_source_path: &Path,
|
||||
_content_type: Option<String>,
|
||||
) -> Result<DedupResultDto, DomainError> {
|
||||
Err(DomainError::internal_error(
|
||||
"DedupService",
|
||||
"DedupService not initialized",
|
||||
))
|
||||
}
|
||||
|
||||
async fn blob_exists(&self, _hash: &str) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn get_blob_metadata(&self, _hash: &str) -> Option<BlobMetadataDto> {
|
||||
None
|
||||
}
|
||||
|
||||
async fn read_blob(&self, _hash: &str) -> Result<Vec<u8>, DomainError> {
|
||||
Err(DomainError::internal_error(
|
||||
"DedupService",
|
||||
"DedupService not initialized",
|
||||
))
|
||||
}
|
||||
|
||||
async fn read_blob_bytes(&self, _hash: &str) -> Result<Bytes, DomainError> {
|
||||
Err(DomainError::internal_error(
|
||||
"DedupService",
|
||||
"DedupService not initialized",
|
||||
))
|
||||
}
|
||||
|
||||
async fn add_reference(&self, _hash: &str) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn remove_reference(&self, _hash: &str) -> Result<bool, DomainError> {
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn hash_bytes(&self, _content: &[u8]) -> String {
|
||||
String::new()
|
||||
}
|
||||
|
||||
async fn hash_file(&self, _path: &Path) -> Result<String, DomainError> {
|
||||
Ok(String::new())
|
||||
}
|
||||
|
||||
async fn get_stats(&self) -> DedupStatsDto {
|
||||
DedupStatsDto::default()
|
||||
}
|
||||
|
||||
async fn flush(&self) -> Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn verify_integrity(&self) -> Result<Vec<String>, DomainError> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// MetadataCachePort
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user