refactor file system operations
the most notable improvement is that uploads are now using streams so they no longer require the entire file to be stored in memory
This commit is contained in:
@@ -3,12 +3,12 @@ use uuid::Uuid;
|
||||
use crate::domain::warren::{
|
||||
models::{
|
||||
auth_session::requests::FetchAuthSessionResponse,
|
||||
file::{AbsoluteFilePath, File, FilePath},
|
||||
file::{AbsoluteFilePath, File},
|
||||
user::{ListAllUsersAndWarrensResponse, LoginUserResponse, User},
|
||||
user_warren::UserWarren,
|
||||
warren::{
|
||||
CreateWarrenDirectoryResponse, DeleteWarrenDirectoryResponse, DeleteWarrenFileResponse,
|
||||
ListWarrenFilesResponse, RenameWarrenEntryResponse, UploadWarrenFilesResponse, Warren,
|
||||
Warren, WarrenLsResponse, WarrenMkdirResponse, WarrenMvResponse, WarrenRmResponse,
|
||||
WarrenSaveResponse, WarrenTouchResponse,
|
||||
},
|
||||
},
|
||||
ports::{AuthNotifier, FileSystemNotifier, WarrenNotifier},
|
||||
@@ -46,7 +46,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
||||
tracing::debug!("[Notifier] Fetched warren {}", warren.name());
|
||||
}
|
||||
|
||||
async fn warren_file_fetched(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
||||
async fn warren_cat(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Fetched file {} in warren {}",
|
||||
path,
|
||||
@@ -54,7 +54,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn warren_files_listed(&self, response: &ListWarrenFilesResponse) {
|
||||
async fn warren_ls(&self, response: &WarrenLsResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Listed {} file(s) in warren {}",
|
||||
response.files().len(),
|
||||
@@ -62,7 +62,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn warren_directory_created(&self, response: &CreateWarrenDirectoryResponse) {
|
||||
async fn warren_mkdir(&self, response: &WarrenMkdirResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Created directory {} in warren {}",
|
||||
response.path(),
|
||||
@@ -70,31 +70,11 @@ impl WarrenNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn warren_directory_deleted(&self, response: &DeleteWarrenDirectoryResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Deleted directory {} in warren {}",
|
||||
response.path(),
|
||||
response.warren().name()
|
||||
);
|
||||
async fn warren_save(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
||||
tracing::debug!("[Notifier] Saved file {} to warren {}", path, warren.name());
|
||||
}
|
||||
|
||||
async fn warren_file_uploaded(&self, warren: &Warren, path: &FilePath) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Uploaded file {} to warren {}",
|
||||
path,
|
||||
warren.name()
|
||||
);
|
||||
}
|
||||
|
||||
async fn warren_files_uploaded(&self, response: &UploadWarrenFilesResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Uploaded {} file(s) to warren {}",
|
||||
response.paths().len(),
|
||||
response.warren().name()
|
||||
);
|
||||
}
|
||||
|
||||
async fn warren_file_deleted(&self, response: &DeleteWarrenFileResponse) {
|
||||
async fn warren_rm(&self, response: &WarrenRmResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Deleted file {} from warren {}",
|
||||
response.path(),
|
||||
@@ -102,7 +82,7 @@ impl WarrenNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn warren_entry_renamed(&self, response: &RenameWarrenEntryResponse) {
|
||||
async fn warren_mv(&self, response: &WarrenMvResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Renamed file {} to {} in warren {}",
|
||||
response.old_path(),
|
||||
@@ -110,36 +90,44 @@ impl WarrenNotifier for NotifierDebugLogger {
|
||||
response.warren().name(),
|
||||
);
|
||||
}
|
||||
|
||||
async fn warren_touch(&self, warren: &Warren, path: &AbsoluteFilePath) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Touched file {} in warren {}",
|
||||
path,
|
||||
warren.name()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl FileSystemNotifier for NotifierDebugLogger {
|
||||
async fn files_listed(&self, files: &Vec<File>) {
|
||||
async fn ls(&self, files: &Vec<File>) {
|
||||
tracing::debug!("[Notifier] Listed {} file(s)", files.len());
|
||||
}
|
||||
|
||||
async fn directory_created(&self, path: &FilePath) {
|
||||
tracing::debug!("[Notifier] Created directory {}", path);
|
||||
}
|
||||
|
||||
async fn directory_deleted(&self, path: &FilePath) {
|
||||
tracing::debug!("[Notifier] Deleted directory {}", path);
|
||||
}
|
||||
|
||||
async fn file_created(&self, path: &FilePath) {
|
||||
tracing::debug!("[Notifier] Created file {}", path);
|
||||
}
|
||||
|
||||
async fn file_fetched(&self, path: &AbsoluteFilePath) {
|
||||
async fn cat(&self, path: &AbsoluteFilePath) {
|
||||
tracing::debug!("[Notifier] Fetched file {path}");
|
||||
}
|
||||
|
||||
async fn file_deleted(&self, path: &FilePath) {
|
||||
async fn mkdir(&self, path: &AbsoluteFilePath) {
|
||||
tracing::debug!("[Notifier] Created directory {}", path);
|
||||
}
|
||||
|
||||
async fn rm(&self, path: &AbsoluteFilePath) {
|
||||
tracing::debug!("[Notifier] Deleted file {}", path);
|
||||
}
|
||||
|
||||
async fn entry_renamed(&self, old_path: &FilePath, new_path: &FilePath) {
|
||||
async fn mv(&self, old_path: &AbsoluteFilePath, new_path: &AbsoluteFilePath) {
|
||||
tracing::debug!("[Notifier] Renamed file {} to {}", old_path, new_path);
|
||||
}
|
||||
|
||||
async fn save(&self, path: &AbsoluteFilePath) {
|
||||
tracing::debug!("[Notifier] Saved file {}", path);
|
||||
}
|
||||
|
||||
async fn touch(&self, path: &AbsoluteFilePath) {
|
||||
tracing::debug!("[Notifier] Touched file {}", path);
|
||||
}
|
||||
}
|
||||
|
||||
impl AuthNotifier for NotifierDebugLogger {
|
||||
@@ -281,19 +269,14 @@ impl AuthNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_file_fetched(
|
||||
&self,
|
||||
user: &User,
|
||||
warren_id: &Uuid,
|
||||
path: &AbsoluteFilePath,
|
||||
) {
|
||||
async fn auth_warren_cat(&self, user: &User, warren_id: &Uuid, path: &AbsoluteFilePath) {
|
||||
tracing::debug!(
|
||||
"[Notifier] User {} fetched file {path} in warren {warren_id}",
|
||||
user.id(),
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_files_listed(&self, user: &User, response: &ListWarrenFilesResponse) {
|
||||
async fn auth_warren_ls(&self, user: &User, response: &WarrenLsResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Listed {} file(s) in warren {} for authenticated user {}",
|
||||
response.files().len(),
|
||||
@@ -302,11 +285,7 @@ impl AuthNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_directory_created(
|
||||
&self,
|
||||
user: &User,
|
||||
response: &CreateWarrenDirectoryResponse,
|
||||
) {
|
||||
async fn auth_warren_mkdir(&self, user: &User, response: &WarrenMkdirResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Created directory {} in warren {} for authenticated user {}",
|
||||
response.path(),
|
||||
@@ -315,29 +294,16 @@ impl AuthNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_directory_deleted(
|
||||
&self,
|
||||
user: &User,
|
||||
response: &DeleteWarrenDirectoryResponse,
|
||||
) {
|
||||
async fn auth_warren_save(&self, user: &User, response: &WarrenSaveResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Deleted directory {} in warren {} for authenticated user {}",
|
||||
"[Notifier] Uploaded file {} to warren {} for authenticated user {}",
|
||||
response.path(),
|
||||
response.warren().name(),
|
||||
user.id(),
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_files_uploaded(&self, user: &User, response: &UploadWarrenFilesResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Uploaded {} file(s) to warren {} for authenticated user {}",
|
||||
response.paths().len(),
|
||||
response.warren().name(),
|
||||
user.id(),
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_file_deleted(&self, user: &User, response: &DeleteWarrenFileResponse) {
|
||||
async fn auth_warren_rm(&self, user: &User, response: &WarrenRmResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Deleted file {} from warren {} for authenticated user {}",
|
||||
response.path(),
|
||||
@@ -346,7 +312,7 @@ impl AuthNotifier for NotifierDebugLogger {
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_entry_renamed(&self, user: &User, response: &RenameWarrenEntryResponse) {
|
||||
async fn auth_warren_mv(&self, user: &User, response: &WarrenMvResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Renamed file {} to {} in warren {} for authenticated user {}",
|
||||
response.old_path(),
|
||||
@@ -355,4 +321,13 @@ impl AuthNotifier for NotifierDebugLogger {
|
||||
user.id(),
|
||||
);
|
||||
}
|
||||
|
||||
async fn auth_warren_touch(&self, user: &User, response: &WarrenTouchResponse) {
|
||||
tracing::debug!(
|
||||
"[Notifier] Touched file {} in warren {} for authenticated user {}",
|
||||
response.path(),
|
||||
response.warren().name(),
|
||||
user.id()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user