mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-24 08:53:04 +10:00
feat(database): Added database corruption dialog
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@@ -29,21 +29,6 @@ router.beforeEach(async () => {
|
|||||||
setupHooks();
|
setupHooks();
|
||||||
initialNavigation(state);
|
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({
|
useHead({
|
||||||
title: "Drop",
|
title: "Drop",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -251,10 +251,11 @@ fn handle_invalid_database(_e: RustbreakError, db_path: PathBuf, games_base_dir:
|
|||||||
let new_path = {
|
let new_path = {
|
||||||
let time = Utc::now().timestamp();
|
let time = Utc::now().timestamp();
|
||||||
let mut base = db_path.clone().into_os_string();
|
let mut base = db_path.clone().into_os_string();
|
||||||
|
base.push(".");
|
||||||
base.push(time.to_string());
|
base.push(time.to_string());
|
||||||
base
|
base
|
||||||
};
|
};
|
||||||
fs::copy(&db_path, &new_path);
|
fs::copy(&db_path, &new_path).unwrap();
|
||||||
|
|
||||||
let db = Database {
|
let db = Database {
|
||||||
auth: None,
|
auth: None,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::fs::remove_dir_all;
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::thread::spawn;
|
use std::thread::spawn;
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{error, info, warn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tauri::Emitter;
|
use tauri::Emitter;
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ use process::process_commands::{kill_game, launch_game};
|
|||||||
use process::process_manager::ProcessManager;
|
use process::process_manager::ProcessManager;
|
||||||
use remote::{gen_drop_url, use_remote};
|
use remote::{gen_drop_url, use_remote};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use tauri_plugin_dialog::DialogExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -182,10 +183,6 @@ fn setup(handle: AppHandle) -> AppState<'static> {
|
|||||||
.and_modify(|v| *v = GameDownloadStatus::Remote {});
|
.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);
|
drop(db_handle);
|
||||||
|
|
||||||
|
|
||||||
@@ -334,6 +331,18 @@ pub fn run() {
|
|||||||
.build(app)
|
.build(app)
|
||||||
.expect("error while setting up tray menu");
|
.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(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.register_asynchronous_uri_scheme_protocol("object", move |_ctx, request, responder| {
|
.register_asynchronous_uri_scheme_protocol("object", move |_ctx, request, responder| {
|
||||||
|
|||||||
Reference in New Issue
Block a user