fix: delete active runtime if it's a symlink
Some checks failed
/ cargo-fmtcheck (push) Has been cancelled
/ cargo-clippy (push) Has been cancelled
/ cargo-test (push) Has been cancelled
/ appimage (push) Has been cancelled

This commit is contained in:
Gabriele Musco 2024-10-19 08:29:22 +02:00 committed by GabMus
parent 68f7bf30c0
commit 91f61e5c4a

View file

@ -5,7 +5,10 @@ use crate::{
xdg::XDG,
};
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::{
fs::remove_file,
path::{Path, PathBuf},
};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ActiveRuntimeInnerRuntime {
@ -63,6 +66,9 @@ pub fn get_current_active_runtime() -> Option<ActiveRuntime> {
}
fn dump_active_runtime_to_path(active_runtime: &ActiveRuntime, path: &Path) -> anyhow::Result<()> {
if path.is_symlink() {
remove_file(path)?;
}
let writer = get_writer(path)?;
serde_json::to_writer_pretty(writer, active_runtime)?;
Ok(())