fix auth errors and add primigenial paper trash

This commit is contained in:
DioCrafts
2025-03-24 16:47:42 +01:00
parent 838ae6e0d4
commit 38b0e9594b
58 changed files with 3701 additions and 135 deletions
@@ -1,4 +1,5 @@
use async_trait::async_trait;
use uuid::Uuid;
use crate::domain::entities::file::File;
use crate::domain::services::path_service::StoragePath;
use crate::common::errors::DomainError;
@@ -18,6 +19,9 @@ pub enum FileRepositoryError {
#[error("Invalid file path: {0}")]
InvalidPath(String),
#[error("Operation not supported: {0}")]
OperationNotSupported(String),
#[error("IO Error: {0}")]
IoError(#[from] std::io::Error),
@@ -90,4 +94,13 @@ pub trait FileRepository: Send + Sync + 'static {
/// Gets the storage path for a file
async fn get_file_path(&self, id: &str) -> FileRepositoryResult<StoragePath>;
/// Moves a file to trash
async fn move_to_trash(&self, file_id: &str) -> FileRepositoryResult<()>;
/// Restores a file from trash
async fn restore_from_trash(&self, file_id: &str, original_path: &str) -> FileRepositoryResult<()>;
/// Permanently deletes a file (used for trash cleanup)
async fn delete_file_permanently(&self, file_id: &str) -> FileRepositoryResult<()>;
}
@@ -16,6 +16,9 @@ pub enum FolderRepositoryError {
#[error("Invalid folder path: {0}")]
InvalidPath(String),
#[error("Operation not supported: {0}")]
OperationNotSupported(String),
#[error("IO Error: {0}")]
IoError(#[from] std::io::Error),
@@ -88,4 +91,13 @@ pub trait FolderRepository: Send + Sync + 'static {
#[deprecated(note = "Use get_folder_by_storage_path instead")]
#[allow(dead_code)]
async fn get_folder_by_path(&self, path: &std::path::PathBuf) -> FolderRepositoryResult<Folder>;
/// Moves a folder to trash
async fn move_to_trash(&self, folder_id: &str) -> FolderRepositoryResult<()>;
/// Restores a folder from trash
async fn restore_from_trash(&self, folder_id: &str, original_path: &str) -> FolderRepositoryResult<()>;
/// Permanently deletes a folder (used for trash cleanup)
async fn delete_folder_permanently(&self, folder_id: &str) -> FolderRepositoryResult<()>;
}
+1 -1
View File
@@ -2,4 +2,4 @@ pub mod file_repository;
pub mod folder_repository;
pub mod user_repository;
pub mod session_repository;
pub mod trash_repository;
@@ -0,0 +1,17 @@
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use uuid::Uuid;
use crate::domain::entities::trashed_item::TrashedItem;
use crate::common::errors::Result;
#[async_trait]
pub trait TrashRepository: Send + Sync {
async fn add_to_trash(&self, item: &TrashedItem) -> Result<()>;
async fn get_trash_items(&self, user_id: &Uuid) -> Result<Vec<TrashedItem>>;
async fn get_trash_item(&self, id: &Uuid, user_id: &Uuid) -> Result<Option<TrashedItem>>;
async fn restore_from_trash(&self, id: &Uuid, user_id: &Uuid) -> Result<()>;
async fn delete_permanently(&self, id: &Uuid, user_id: &Uuid) -> Result<()>;
async fn clear_trash(&self, user_id: &Uuid) -> Result<()>;
async fn get_expired_items(&self) -> Result<Vec<TrashedItem>>;
}