commit 8263bdd21dfcb26ff59c4f6274ab33e0b145968c
parent b64cf27038f04368af8f25aa80782d37471e6303
Author: Daniel GarcĂa <dani-garcia@users.noreply.github.com>
Date: Fri, 15 Jul 2022 19:03:49 +0200
Merge branch 'ruifung-main' into main
Diffstat:
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs
@@ -1,6 +1,7 @@
use std::collections::{HashMap, HashSet};
use chrono::{NaiveDateTime, Utc};
+use futures::{stream, stream::StreamExt};
use rocket::fs::TempFile;
use rocket::serde::json::Json;
use rocket::{
@@ -17,7 +18,7 @@ use crate::{
CONFIG,
};
-use futures::{stream, stream::StreamExt};
+use super::folders::FolderData;
pub fn routes() -> Vec<Route> {
// Note that many routes have an `admin` variant; this seems to be
@@ -212,7 +213,8 @@ pub struct CipherData {
Card = 3,
Identity = 4
*/
- pub Type: i32, // TODO: Change this to NumberOrString
+ pub Type: i32,
+ // TODO: Change this to NumberOrString
pub Name: String,
Notes: Option<String>,
Fields: Option<Value>,
@@ -230,7 +232,8 @@ pub struct CipherData {
// These are used during key rotation
#[serde(rename = "Attachments")]
- _Attachments: Option<Value>, // Unused, contains map of {id: filename}
+ _Attachments: Option<Value>,
+ // Unused, contains map of {id: filename}
Attachments2: Option<HashMap<String, Attachments2Data>>,
// The revision datetime (in ISO 8601 format) of the client's local copy
@@ -470,8 +473,6 @@ pub async fn update_cipher_from_data(
Ok(())
}
-use super::folders::FolderData;
-
#[derive(Deserialize)]
#[allow(non_snake_case)]
struct ImportData {
@@ -998,7 +999,9 @@ async fn save_attachment(
attachment.save(&conn).await.expect("Error saving attachment");
}
- data.data.persist_to(file_path).await?;
+ if let Err(_err) = data.data.persist_to(&file_path).await {
+ data.data.move_copy_to(file_path).await?
+ }
nt.send_cipher_update(UpdateType::CipherUpdate, &cipher, &cipher.update_users_revision(&conn).await).await;
diff --git a/src/api/core/sends.rs b/src/api/core/sends.rs
@@ -225,7 +225,10 @@ async fn post_send_file(data: Form<UploadData<'_>>, headers: Headers, conn: DbCo
let folder_path = tokio::fs::canonicalize(&CONFIG.sends_folder()).await?.join(&send.uuid);
let file_path = folder_path.join(&file_id);
tokio::fs::create_dir_all(&folder_path).await?;
- data.persist_to(&file_path).await?;
+
+ if let Err(_err) = data.persist_to(&file_path).await {
+ 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() {