mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
feat: local backup (#5054)
* feat: local backup * refactor(backup): make local backup helpers synchronous and clean up redundant checks - Converted local backup helpers to synchronous functions to remove unused async warnings and align command signatures. - Updated list/delete/export commands to call the sync feature functions directly without awaits while preserving behavior. - Simplified destination directory creation to always ensure parent folders exist without redundant checks, satisfying Clippy.
This commit is contained in:
33
src-tauri/src/cmd/backup.rs
Normal file
33
src-tauri/src/cmd/backup.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use super::CmdResult;
|
||||
use crate::{feat, wrap_err};
|
||||
use feat::LocalBackupFile;
|
||||
|
||||
/// Create a local backup
|
||||
#[tauri::command]
|
||||
pub fn create_local_backup() -> CmdResult<()> {
|
||||
wrap_err!(feat::create_local_backup())
|
||||
}
|
||||
|
||||
/// List local backups
|
||||
#[tauri::command]
|
||||
pub fn list_local_backup() -> CmdResult<Vec<LocalBackupFile>> {
|
||||
wrap_err!(feat::list_local_backup())
|
||||
}
|
||||
|
||||
/// Delete local backup
|
||||
#[tauri::command]
|
||||
pub fn delete_local_backup(filename: String) -> CmdResult<()> {
|
||||
wrap_err!(feat::delete_local_backup(filename))
|
||||
}
|
||||
|
||||
/// Restore local backup
|
||||
#[tauri::command]
|
||||
pub async fn restore_local_backup(filename: String) -> CmdResult<()> {
|
||||
wrap_err!(feat::restore_local_backup(filename).await)
|
||||
}
|
||||
|
||||
/// Export local backup to a user selected destination
|
||||
#[tauri::command]
|
||||
pub fn export_local_backup(filename: String, destination: String) -> CmdResult<()> {
|
||||
wrap_err!(feat::export_local_backup(filename, destination))
|
||||
}
|
||||
@@ -4,6 +4,7 @@ pub type CmdResult<T = ()> = Result<T, String>;
|
||||
|
||||
// Command modules
|
||||
pub mod app;
|
||||
pub mod backup;
|
||||
pub mod clash;
|
||||
pub mod lightweight;
|
||||
pub mod media_unlock_checker;
|
||||
@@ -21,6 +22,7 @@ pub mod webdav;
|
||||
|
||||
// Re-export all command functions for backwards compatibility
|
||||
pub use app::*;
|
||||
pub use backup::*;
|
||||
pub use clash::*;
|
||||
pub use lightweight::*;
|
||||
pub use media_unlock_checker::*;
|
||||
|
||||
Reference in New Issue
Block a user