Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
528 changes: 528 additions & 0 deletions apps/desktop/src-tauri/src/backups.rs

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tauri::{
};
use tauri_plugin_autostart::ManagerExt;

mod backups;
mod hindsight;
mod honcho;
mod installer;
Expand Down Expand Up @@ -630,6 +631,22 @@ async fn desktop_services_action_all(
services::action_all(&app, &action, approved).await
}

#[tauri::command]
async fn desktop_database_backup(
app: AppHandle,
approved: bool,
) -> Result<Option<backups::DatabaseActionResult>, String> {
backups::backup(&app, approved).await
}

#[tauri::command]
async fn desktop_database_restore(
app: AppHandle,
approved: bool,
) -> Result<Option<backups::DatabaseActionResult>, String> {
backups::restore(&app, approved).await
}

#[tauri::command]
fn desktop_update_status(updater: State<'_, updater::UpdaterState>) -> updater::UpdateSnapshot {
updater.status()
Expand Down Expand Up @@ -1145,6 +1162,8 @@ pub fn run() {
desktop_honcho_status,
desktop_service_action,
desktop_services_action_all,
desktop_database_backup,
desktop_database_restore,
desktop_update_status,
desktop_update_check,
desktop_update_install,
Expand Down
13 changes: 13 additions & 0 deletions apps/desktop/src-tauri/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ pub async fn pick(app: AppHandle, kind: &str) -> Result<Option<String>, String>
.pick_file(move |path| {
let _ = sender.send(path);
}),
"backup-export" => dialog
.set_title("Export a verified Cortana database backup")
.set_file_name("cortana-backup.sqlite3")
.add_filter("Cortana database backup", &["sqlite3"])
.save_file(move |path| {
let _ = sender.send(path);
}),
"backup-import" => dialog
.set_title("Restore a Cortana database backup")
.add_filter("Cortana database backup", &["sqlite3"])
.pick_file(move |path| {
let _ = sender.send(path);
}),
_ => return Err("unsupported native path picker".into()),
}
let selected = receiver
Expand Down
22 changes: 22 additions & 0 deletions apps/desktop/src-tauri/src/source_jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1664,21 +1664,27 @@ fn terminal_summary(operation: &str, status: &str, disconnected: bool, kind: &st
"github" => {
"GitHub authorization completed and the token was stored privately.".into()
}
"slack" => {
"Slack authorization completed and the user token was stored privately.".into()
}
_ => "Google authorization completed and the token was stored privately.".into(),
},
("authorization", "cancelled", _) => match kind {
"discord" => "Discord authorization was cancelled.".into(),
"github" => "GitHub authorization was cancelled.".into(),
"slack" => "Slack authorization was cancelled.".into(),
_ => "Google authorization was cancelled.".into(),
},
("authorization", _, true) => match kind {
"discord" => "Discord authorization ended without a process result.".into(),
"github" => "GitHub authorization ended without a process result.".into(),
"slack" => "Slack authorization ended without a process result.".into(),
_ => "Google authorization ended without a process result.".into(),
},
("authorization", _, false) => match kind {
"discord" => "Discord authorization failed.".into(),
"github" => "GitHub authorization failed.".into(),
"slack" => "Slack authorization failed.".into(),
_ => "Google authorization failed.".into(),
},
(_, "succeeded", _) => "Source validation passed. No documents were indexed.".into(),
Expand Down Expand Up @@ -2783,6 +2789,10 @@ mod tests {
terminal_summary("authorization", "succeeded", false, "github")
.contains("GitHub authorization completed")
);
assert!(
terminal_summary("authorization", "succeeded", false, "slack")
.contains("Slack authorization completed")
);
assert!(
terminal_summary("authorization", "succeeded", false, "gmail")
.contains("Google authorization completed")
Expand All @@ -2791,14 +2801,26 @@ mod tests {
terminal_summary("authorization", "cancelled", false, "discord")
.contains("Discord authorization was cancelled")
);
assert!(
terminal_summary("authorization", "cancelled", false, "slack")
.contains("Slack authorization was cancelled")
);
assert!(
terminal_summary("authorization", "failed", true, "discord")
.contains("Discord authorization ended without a process result")
);
assert!(
terminal_summary("authorization", "failed", true, "slack")
.contains("Slack authorization ended without a process result")
);
assert!(
terminal_summary("authorization", "failed", false, "discord")
.contains("Discord authorization failed")
);
assert!(
terminal_summary("authorization", "failed", false, "slack")
.contains("Slack authorization failed")
);
}

#[test]
Expand Down
Loading
Loading