From 8f043a3ce2760f7b689b40d6be5a17bc82c4e3c2 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Thu, 2 May 2024 10:57:00 +0700 Subject: [PATCH] Create push notificaiton token dir --- src/common/pushnoti.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/common/pushnoti.rs b/src/common/pushnoti.rs index 0e78499..aaed6c8 100644 --- a/src/common/pushnoti.rs +++ b/src/common/pushnoti.rs @@ -74,6 +74,31 @@ impl PushNotiThread { // let vapid_key = "????"; let token_path = dirs::config_dir().map(|mut d| { + fs::create_dir(&d) + .map_or_else( + |res| { + if let std::io::ErrorKind::AlreadyExists = res.kind() { + Ok(()) + } else { + Err(res) + } + }, + Ok, + ) + .expect("Unable to create directory for push notification settings: {d:?}"); + d.push("neolink"); + fs::create_dir(&d) + .map_or_else( + |res| { + if let std::io::ErrorKind::AlreadyExists = res.kind() { + Ok(()) + } else { + Err(res) + } + }, + Ok, + ) + .expect("Unable to create directory for push notification settings: {d:?}"); d.push("./neolink_token.toml"); d });