mirror of
				https://github.com/dani-garcia/vaultwarden.git
				synced 2025-10-31 02:08:20 +02:00 
			
		
		
		
	Remove option and use unwrap_or_else to fall back to copy behavior.
This commit is contained in:
		| @@ -17,7 +17,7 @@ use crate::{ | ||||
|     CONFIG, | ||||
| }; | ||||
|  | ||||
| use futures::{stream, stream::StreamExt}; | ||||
| use futures::{stream, stream::StreamExt, TryFutureExt}; | ||||
|  | ||||
| pub fn routes() -> Vec<Route> { | ||||
|     // Note that many routes have an `admin` variant; this seems to be | ||||
| @@ -998,11 +998,9 @@ async fn save_attachment( | ||||
|         attachment.save(&conn).await.expect("Error saving attachment"); | ||||
|     } | ||||
|  | ||||
|     if CONFIG.uploads_use_copy() { | ||||
|         data.data.move_copy_to(file_path).await?; | ||||
|     } else { | ||||
|         data.data.persist_to(file_path).await?; | ||||
|     } | ||||
|     data.data.persist_to(&file_path) | ||||
|         .unwrap_or_else(data.data.move_copy_to(&file_path)) | ||||
|         .await?; | ||||
|  | ||||
|     nt.send_cipher_update(UpdateType::CipherUpdate, &cipher, &cipher.update_users_revision(&conn).await).await; | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| use std::path::Path; | ||||
|  | ||||
| use chrono::{DateTime, Duration, Utc}; | ||||
| use futures::TryFutureExt; | ||||
| use rocket::form::Form; | ||||
| use rocket::fs::NamedFile; | ||||
| use rocket::fs::TempFile; | ||||
| @@ -226,11 +227,9 @@ async fn post_send_file(data: Form<UploadData<'_>>, headers: Headers, conn: DbCo | ||||
|     let file_path = folder_path.join(&file_id); | ||||
|     tokio::fs::create_dir_all(&folder_path).await?; | ||||
|  | ||||
|     if CONFIG.uploads_use_copy() { | ||||
|         data.move_copy_to(&file_path).await?; | ||||
|     } else { | ||||
|         data.persist_to(&file_path).await?; | ||||
|     } | ||||
|     data.persist_to(&file_path) | ||||
|         .unwrap_or_else(data.move_copy_to(&file_path)) | ||||
|         .await?; | ||||
|  | ||||
|     let mut data_value: Value = serde_json::from_str(&send.data)?; | ||||
|     if let Some(o) = data_value.as_object_mut() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user