Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32220150
D13929.1765190900.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D13929.1765190900.diff
View Options
diff --git a/native/native_rust_library/src/backup/upload_handler.rs b/native/native_rust_library/src/backup/upload_handler.rs
--- a/native/native_rust_library/src/backup/upload_handler.rs
+++ b/native/native_rust_library/src/backup/upload_handler.rs
@@ -243,28 +243,33 @@
Ok(())
}
+ async fn remove_file_if_exists(path: &String) -> Result<(), Box<dyn Error>> {
+ match tokio::fs::remove_file(path).await {
+ Ok(()) => Ok(()),
+ Err(err) if err.kind() == ErrorKind::NotFound => Ok(()),
+ Err(err) => Err(err.into()),
+ }
+ }
pub async fn cleanup_files(backup_id: String) {
let backup_files_cleanup = async {
- let user_data_path = get_backup_file_path(&backup_id, false)?;
- tokio::fs::remove_file(&user_data_path).await?;
- let user_keys_path = get_backup_user_keys_file_path(&backup_id)?;
- tokio::fs::remove_file(&user_keys_path).await?;
- let attachments_path = get_backup_file_path(&backup_id, true)?;
- match tokio::fs::remove_file(&attachments_path).await {
- Ok(()) => Result::<_, Box<dyn Error>>::Ok(()),
- Err(err) if err.kind() == ErrorKind::NotFound => Ok(()),
- Err(err) => Err(err.into()),
- }?;
- let siwe_backup_msg_path = get_siwe_backup_message_path(&backup_id)?;
- match tokio::fs::remove_file(&siwe_backup_msg_path).await {
- Ok(()) => Result::<_, Box<dyn Error>>::Ok(()),
- Err(err) if err.kind() == ErrorKind::NotFound => Ok(()),
- Err(err) => Err(err.into()),
+ let paths_to_remove = vec![
+ get_backup_file_path(&backup_id, false)?,
+ get_backup_user_keys_file_path(&backup_id)?,
+ get_backup_file_path(&backup_id, true)?,
+ get_siwe_backup_message_path(&backup_id)?,
+ ];
+
+ for path in paths_to_remove {
+ if let Err(e) = remove_file_if_exists(&path).await {
+ println!("Error occurred while removing a file: {:?}", e);
+ }
}
+
+ Ok::<(), Box<dyn Error>>(())
};
if let Err(err) = backup_files_cleanup.await {
- println!("Error when cleaning up the backup files: {err:?}");
+ println!("Error when cleaning up the backup files: {:?}", err);
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 8, 10:48 AM (3 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5847961
Default Alt Text
D13929.1765190900.diff (2 KB)
Attached To
Mode
D13929: [backup-client][native_rust_library] update file cleanup to ignore missing files
Attached
Detach File
Event Timeline
Log In to Comment