mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-20 11:35:48 +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,
|
||||
};
|
||||
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(())
|
||||
|
|
Loading…
Add table
Reference in a new issue