mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
feat(database): Added database corruption dialog
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
15
app.vue
15
app.vue
@ -29,21 +29,6 @@ router.beforeEach(async () => {
|
||||
setupHooks();
|
||||
initialNavigation(state);
|
||||
|
||||
listen("database_corrupted", (event) => {
|
||||
createModal(
|
||||
ModalType.Notification,
|
||||
{
|
||||
title: "Database corrupted",
|
||||
description: `Drop encountered an error while reading your download. A copy can be found at: "${(
|
||||
event.payload as unknown as string
|
||||
).toString()}"`,
|
||||
buttonText: "Close"
|
||||
},
|
||||
(e, c) => c()
|
||||
);
|
||||
|
||||
})
|
||||
|
||||
useHead({
|
||||
title: "Drop",
|
||||
});
|
||||
|
||||
@ -251,10 +251,11 @@ fn handle_invalid_database(_e: RustbreakError, db_path: PathBuf, games_base_dir:
|
||||
let new_path = {
|
||||
let time = Utc::now().timestamp();
|
||||
let mut base = db_path.clone().into_os_string();
|
||||
base.push(".");
|
||||
base.push(time.to_string());
|
||||
base
|
||||
};
|
||||
fs::copy(&db_path, &new_path);
|
||||
fs::copy(&db_path, &new_path).unwrap();
|
||||
|
||||
let db = Database {
|
||||
auth: None,
|
||||
|
||||
@ -2,7 +2,7 @@ use std::fs::remove_dir_all;
|
||||
use std::sync::Mutex;
|
||||
use std::thread::spawn;
|
||||
|
||||
use log::{error, info};
|
||||
use log::{error, info, warn};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::Emitter;
|
||||
use tauri::{AppHandle, Manager};
|
||||
|
||||
@ -42,6 +42,7 @@ use process::process_commands::{kill_game, launch_game};
|
||||
use process::process_manager::ProcessManager;
|
||||
use remote::{gen_drop_url, use_remote};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
@ -182,10 +183,6 @@ fn setup(handle: AppHandle) -> AppState<'static> {
|
||||
.and_modify(|v| *v = GameDownloadStatus::Remote {});
|
||||
}
|
||||
|
||||
if let Some(original) = db_handle.prev_database.take() {
|
||||
warn!("Database corrupted. Original file at {}", original.canonicalize().unwrap().to_string_lossy().to_string());
|
||||
handle.emit("database_corrupted", original.to_string_lossy().to_string()).unwrap();
|
||||
}
|
||||
drop(db_handle);
|
||||
|
||||
|
||||
@ -334,6 +331,18 @@ pub fn run() {
|
||||
.build(app)
|
||||
.expect("error while setting up tray menu");
|
||||
|
||||
{
|
||||
let mut db_handle = DB.borrow_data_mut().unwrap();
|
||||
if let Some(original) = db_handle.prev_database.take() {
|
||||
warn!("Database corrupted. Original file at {}", original.canonicalize().unwrap().to_string_lossy().to_string());
|
||||
app.dialog()
|
||||
.message("Database corrupted. A copy has been saved at: ".to_string() + original.to_str().unwrap())
|
||||
.title("Database corrupted")
|
||||
.show(|_| {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.register_asynchronous_uri_scheme_protocol("object", move |_ctx, request, responder| {
|
||||
|
||||
Reference in New Issue
Block a user