Save progress when interrupted
This commit is contained in:
parent
5f6c087097
commit
b4ce27a1b9
5 changed files with 40 additions and 1 deletions
14
src/main.rs
14
src/main.rs
|
@ -6,6 +6,13 @@ mod schema;
|
|||
mod steam;
|
||||
mod wiki;
|
||||
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
};
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::{
|
||||
manifest::{Manifest, ManifestOverride},
|
||||
resource::ResourceFile,
|
||||
|
@ -14,6 +21,11 @@ use crate::{
|
|||
};
|
||||
|
||||
pub const REPO: &str = env!("CARGO_MANIFEST_DIR");
|
||||
static CANCEL: Lazy<Arc<AtomicBool>> = Lazy::new(|| Arc::new(AtomicBool::new(false)));
|
||||
|
||||
pub fn should_cancel() -> bool {
|
||||
CANCEL.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
@ -90,6 +102,8 @@ impl Error {
|
|||
async fn main() {
|
||||
let cli = cli::parse();
|
||||
|
||||
signal_hook::flag::register(signal_hook::consts::SIGINT, (*CANCEL).clone()).unwrap();
|
||||
|
||||
let mut wiki_cache = WikiCache::load().unwrap();
|
||||
let mut wiki_meta_cache = WikiMetaCache::load().unwrap();
|
||||
let mut steam_cache = SteamCache::load().unwrap();
|
||||
|
|
Reference in a new issue