perf: eliminate Vec<u8> buffer paths — all uploads now stream to disk
Issue #4 (HIGH): save_file(Vec<u8>) and update_file_content(Vec<u8>) accepted up to 10 MB of contiguous memory per request. While the main upload paths already used streaming, the WebDAV compat methods (create_file, update_file) and the empty-file handler still used the buffered path, creating a .to_vec() copy. Changes: - FileWritePort trait: remove save_file(Vec<u8>) and update_file_content(Vec<u8>) — only streaming variants remain - FileUploadUseCase trait: remove upload_file(Vec<u8>) - file_upload_service.rs: create_file() and update_file() now spool &[u8] to NamedTempFile + Sha256::digest, then delegate to streaming path (save_file_from_temp / update_file_streaming) - file_handler.rs: empty file uploads use upload_file_streaming with - FileBlobWriteRepository: remove save_file and update_file_content impls - StubFileWritePort, StubFileUploadUseCase, MockFileRepository: remove corresponding dead method impls Impact: impossible to accidentally use a buffered upload path. All content goes through streaming with ~256 KB peak RAM. -166 LOC.
This commit is contained in:
@@ -209,16 +209,6 @@ impl FileReadPort for MockFileRepository {
|
||||
|
||||
#[async_trait]
|
||||
impl FileWritePort for MockFileRepository {
|
||||
async fn save_file(
|
||||
&self,
|
||||
_name: String,
|
||||
_folder_id: Option<String>,
|
||||
_content_type: String,
|
||||
_content: Vec<u8>,
|
||||
) -> std::result::Result<File, DomainError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
async fn save_file_from_temp(
|
||||
&self,
|
||||
_name: String,
|
||||
@@ -251,14 +241,6 @@ impl FileWritePort for MockFileRepository {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn update_file_content(
|
||||
&self,
|
||||
_file_id: &str,
|
||||
_content: Vec<u8>,
|
||||
) -> std::result::Result<(), DomainError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn update_file_content_from_temp(
|
||||
&self,
|
||||
_file_id: &str,
|
||||
@@ -514,10 +496,7 @@ mod tests {
|
||||
// Arrange
|
||||
let trashed_files = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trashed_folders = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(
|
||||
trashed_files.clone(),
|
||||
trashed_folders.clone(),
|
||||
));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(trashed_files.clone(), trashed_folders.clone()));
|
||||
let file_repo = Arc::new(MockFileRepository::new(trashed_files));
|
||||
let folder_repo = Arc::new(MockFolderRepository::new(trashed_folders));
|
||||
|
||||
@@ -588,10 +567,7 @@ mod tests {
|
||||
// Arrange
|
||||
let trashed_files = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trashed_folders = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(
|
||||
trashed_files.clone(),
|
||||
trashed_folders.clone(),
|
||||
));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(trashed_files.clone(), trashed_folders.clone()));
|
||||
let file_repo = Arc::new(MockFileRepository::new(trashed_files));
|
||||
let folder_repo = Arc::new(MockFolderRepository::new(trashed_folders));
|
||||
|
||||
@@ -653,10 +629,7 @@ mod tests {
|
||||
// Arrange
|
||||
let trashed_files = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trashed_folders = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(
|
||||
trashed_files.clone(),
|
||||
trashed_folders.clone(),
|
||||
));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(trashed_files.clone(), trashed_folders.clone()));
|
||||
let file_repo = Arc::new(MockFileRepository::new(trashed_files));
|
||||
let folder_repo = Arc::new(MockFolderRepository::new(trashed_folders));
|
||||
|
||||
@@ -723,10 +696,7 @@ mod tests {
|
||||
// Arrange
|
||||
let trashed_files = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trashed_folders = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(
|
||||
trashed_files.clone(),
|
||||
trashed_folders.clone(),
|
||||
));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(trashed_files.clone(), trashed_folders.clone()));
|
||||
let file_repo = Arc::new(MockFileRepository::new(trashed_files));
|
||||
let folder_repo = Arc::new(MockFolderRepository::new(trashed_folders));
|
||||
|
||||
@@ -792,10 +762,7 @@ mod tests {
|
||||
// Arrange
|
||||
let trashed_files = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trashed_folders = Arc::new(Mutex::new(HashMap::new()));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(
|
||||
trashed_files.clone(),
|
||||
trashed_folders.clone(),
|
||||
));
|
||||
let trash_repo = Arc::new(MockTrashRepository::new(trashed_files.clone(), trashed_folders.clone()));
|
||||
let file_repo = Arc::new(MockFileRepository::new(trashed_files));
|
||||
let folder_repo = Arc::new(MockFolderRepository::new(trashed_folders));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user