mirror of
https://github.com/egor-white/zaprett.git
synced 2025-12-10 05:19:42 +05:00
Merge pull request #7 from sqlerrorthing/refactor/rust/autostart
refactor: autostart
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user