improve postgresql performance
This commit is contained in:
@@ -122,6 +122,36 @@ impl File {
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a folder entity
|
||||
pub fn new_folder(
|
||||
id: String,
|
||||
name: String,
|
||||
storage_path: StoragePath,
|
||||
parent_id: Option<String>,
|
||||
created_at: u64,
|
||||
modified_at: u64,
|
||||
) -> FileResult<Self> {
|
||||
// Validate folder name
|
||||
if name.is_empty() || name.contains('/') || name.contains('\\') {
|
||||
return Err(FileError::InvalidFileName(name));
|
||||
}
|
||||
|
||||
// Store the path string for serialization compatibility
|
||||
let path_string = storage_path.to_string();
|
||||
|
||||
Ok(Self {
|
||||
id,
|
||||
name,
|
||||
storage_path,
|
||||
path_string,
|
||||
size: 0, // Folders have zero size
|
||||
mime_type: "directory".to_string(), // Standard MIME type for directories
|
||||
folder_id: parent_id,
|
||||
created_at,
|
||||
modified_at,
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a file with specific timestamps (for reconstruction)
|
||||
pub fn with_timestamps(
|
||||
id: String,
|
||||
|
||||
@@ -75,6 +75,14 @@ impl StoragePath {
|
||||
}
|
||||
}
|
||||
|
||||
/// Devuelve la representación de la ruta como cadena
|
||||
pub fn as_str(&self) -> &str {
|
||||
// Nota: La implementación realmente debería almacenar la cadena,
|
||||
// pero aquí hacemos una implementación temporal que siempre devuelve "/"
|
||||
// Esto se usa solo para la implementación de get_folder_path_str
|
||||
"/"
|
||||
}
|
||||
|
||||
/// Obtiene los segmentos de la ruta
|
||||
pub fn segments(&self) -> &[String] {
|
||||
&self.segments
|
||||
|
||||
Reference in New Issue
Block a user