mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-17 22:41:35 +00:00
fix: delete active runtime if it's a symlink
This commit is contained in:
parent
68f7bf30c0
commit
91f61e5c4a
1 changed files with 7 additions and 1 deletions
|
@ -5,7 +5,10 @@ use crate::{
|
||||||
xdg::XDG,
|
xdg::XDG,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::{Path, PathBuf};
|
use std::{
|
||||||
|
fs::remove_file,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ActiveRuntimeInnerRuntime {
|
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<()> {
|
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)?;
|
let writer = get_writer(path)?;
|
||||||
serde_json::to_writer_pretty(writer, active_runtime)?;
|
serde_json::to_writer_pretty(writer, active_runtime)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue