feat(backup): 实例备份第3轮——注册 15 个 Tauri 备份命令并补齐 ACL 权限
This commit is contained in:
1 parent
e8f10ab1ef
commit
7414477bbd
2 files changed
+152
No files matched your search
@@ -428,6 +428,21 @@ fn main() {
|
||||
InlinedPlugin::new()
|
||||
.commands(&[
|
||||
"instance_remove",
|
||||
"instance_get_backup_repository_status",
|
||||
"instance_move_backup_repository",
|
||||
"instance_get_backup_config",
|
||||
"instance_normalize_backup_exclusion",
|
||||
"instance_enable_backups",
|
||||
"instance_update_backup_exclusions",
|
||||
"instance_disable_backups",
|
||||
"instance_start_backup",
|
||||
"instance_cancel_backup",
|
||||
"instance_list_backup_operations",
|
||||
"instance_list_backups",
|
||||
"instance_delete_backup",
|
||||
"instance_get_backup_restore_preview",
|
||||
"instance_restore_backup",
|
||||
"instance_get_backup_delete_summary",
|
||||
"instance_create_direct_link",
|
||||
"instance_sync_direct_links",
|
||||
"instance_get",
|
||||
|
||||
@@ -25,6 +25,21 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("instance")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
instance_remove,
|
||||
instance_get_backup_repository_status,
|
||||
instance_move_backup_repository,
|
||||
instance_get_backup_config,
|
||||
instance_normalize_backup_exclusion,
|
||||
instance_enable_backups,
|
||||
instance_update_backup_exclusions,
|
||||
instance_disable_backups,
|
||||
instance_start_backup,
|
||||
instance_cancel_backup,
|
||||
instance_list_backup_operations,
|
||||
instance_list_backups,
|
||||
instance_delete_backup,
|
||||
instance_get_backup_restore_preview,
|
||||
instance_restore_backup,
|
||||
instance_get_backup_delete_summary,
|
||||
instance_create_direct_link,
|
||||
instance_sync_direct_links,
|
||||
instance_get,
|
||||
@@ -1699,3 +1714,125 @@ pub async fn instance_open_screenshot<R: tauri::Runtime>(
|
||||
.map_err(|e| std::io::Error::other(e.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ===== 实例备份命令(移植自 Axolotl) =====
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_get_backup_repository_status() -> Result<
|
||||
theseus::instance::BackupRepositoryStatus,
|
||||
> {
|
||||
Ok(theseus::instance::get_backup_repository_status().await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_move_backup_repository(
|
||||
destination: PathBuf,
|
||||
) -> Result<uuid::Uuid> {
|
||||
Ok(theseus::instance::move_backup_repository(destination).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_get_backup_config(
|
||||
instance_id: &str,
|
||||
) -> Result<theseus::instance::InstanceBackupConfig> {
|
||||
Ok(theseus::instance::get_backup_config(instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_normalize_backup_exclusion(
|
||||
instance_id: &str,
|
||||
selected_path: PathBuf,
|
||||
kind: theseus::instance::BackupExclusionKind,
|
||||
) -> Result<theseus::instance::BackupExclusion> {
|
||||
Ok(theseus::instance::get_backup_exclusion_from_path(
|
||||
instance_id,
|
||||
selected_path,
|
||||
kind,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_enable_backups(
|
||||
instance_id: &str,
|
||||
excluded_paths: Vec<theseus::instance::BackupExclusion>,
|
||||
) -> Result<theseus::instance::InstanceBackupConfig> {
|
||||
Ok(theseus::instance::enable_backups(instance_id, excluded_paths).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_update_backup_exclusions(
|
||||
instance_id: &str,
|
||||
excluded_paths: Vec<theseus::instance::BackupExclusion>,
|
||||
) -> Result<theseus::instance::InstanceBackupConfig> {
|
||||
Ok(
|
||||
theseus::instance::update_backup_exclusions(
|
||||
instance_id,
|
||||
excluded_paths,
|
||||
)
|
||||
.await?,
|
||||
)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_disable_backups(instance_id: &str) -> Result<()> {
|
||||
Ok(theseus::instance::disable_backups(instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_start_backup(instance_id: String) -> Result<uuid::Uuid> {
|
||||
Ok(theseus::instance::start_backup_snapshot(instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_cancel_backup(
|
||||
operation_id: uuid::Uuid,
|
||||
) -> Result<bool> {
|
||||
Ok(theseus::instance::cancel_backup(operation_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_list_backup_operations(
|
||||
instance_id: Option<String>,
|
||||
active_only: bool,
|
||||
) -> Result<Vec<theseus::instance::BackupOperation>> {
|
||||
Ok(theseus::instance::list_backup_operations(
|
||||
instance_id.as_deref(),
|
||||
active_only,
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_list_backups(
|
||||
instance_id: &str,
|
||||
) -> Result<Vec<theseus::instance::BackupSnapshot>> {
|
||||
Ok(theseus::instance::list_backup_snapshots(instance_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_delete_backup(snapshot_id: &str) -> Result<()> {
|
||||
Ok(theseus::instance::delete_backup_snapshot(snapshot_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_get_backup_restore_preview(
|
||||
snapshot_id: &str,
|
||||
) -> Result<uuid::Uuid> {
|
||||
Ok(theseus::instance::get_backup_restore_preview(snapshot_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_restore_backup(
|
||||
snapshot_id: &str,
|
||||
plan_token: &str,
|
||||
) -> Result<uuid::Uuid> {
|
||||
Ok(theseus::instance::restore_snapshot(snapshot_id, plan_token).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn instance_get_backup_delete_summary(
|
||||
instance_id: &str,
|
||||
) -> Result<theseus::instance::BackupDeleteSummary> {
|
||||
Ok(theseus::instance::get_backup_delete_summary(instance_id).await?)
|
||||
}
|
||||
Reference in new issue
Block a user