Merge pull request #7 from sqlerrorthing/refactor/rust/autostart

refactor: autostart
This commit is contained in:
egor-white
2025-11-03 16:28:23 +03:00
committed by GitHub

View File

@@ -1,20 +1,21 @@
use tokio::fs::File;
use tokio::fs;
use crate::MODULE_PATH;
use std::path::PathBuf;
use std::sync::LazyLock;
use tokio::fs;
use tokio::fs::File;
static AUTOSTART: LazyLock<PathBuf> = LazyLock::new(|| MODULE_PATH.join("autostart"));
pub async fn set_autostart(autostart: bool) -> Result<(), anyhow::Error> {
let autostart_path = MODULE_PATH.join("autostart");
if autostart {
File::create(autostart_path).await?;
File::create(&*AUTOSTART).await?;
} else {
fs::remove_file(autostart_path).await?;
fs::remove_file(&*AUTOSTART).await?;
}
Ok(())
}
pub fn get_autostart() {
let file = MODULE_PATH.join("autostart");
println!("{}", file.exists());
pub fn get_autostart() -> bool {
AUTOSTART.exists()
}