From 377d07675df0a3b4a83ceef472a0627250f68c03 Mon Sep 17 00:00:00 2001 From: ink0rr Date: Fri, 19 Jul 2024 04:57:57 +0700 Subject: [PATCH 1/3] fix: prevent incorrect symlink after changing export path --- src/rgl/runner.rs | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/rgl/runner.rs b/src/rgl/runner.rs index 7ed3efb..5a00bbd 100644 --- a/src/rgl/runner.rs +++ b/src/rgl/runner.rs @@ -1,8 +1,7 @@ use super::{Config, Session}; -use crate::fs::{copy_dir, empty_dir, rimraf, sync_dir, try_symlink}; +use crate::fs::{copy_dir, empty_dir, rimraf, symlink, sync_dir, try_symlink}; use crate::{info, measure_time, warn}; use anyhow::Result; -use std::fs::create_dir_all; use std::path::Path; pub fn run_or_watch(profile_name: &str, watch: bool, cached: bool) -> Result<()> { @@ -25,28 +24,15 @@ pub fn run_or_watch(profile_name: &str, watch: bool, cached: bool) -> Result<()> sync_dir(bp, &target_bp)?; sync_dir(rp, &target_rp)?; } else { - empty_dir(&temp)?; rimraf(&target_bp)?; rimraf(&target_rp)?; copy_dir(bp, &target_bp)?; copy_dir(rp, &target_rp)?; } - create_dir_all(&temp)?; - if !temp_bp.is_symlink() { - if temp_bp.exists() { - rimraf(&temp_bp)?; - } - try_symlink(&target_bp, &temp_bp)?; - } - if !temp_rp.is_symlink() { - if temp_rp.exists() { - rimraf(&temp_rp)?; - } - try_symlink(&target_rp, &temp_rp)?; - } - if !temp_data.is_symlink() { - try_symlink(config.get_data_path(), temp_data)?; - } + empty_dir(&temp)?; + symlink(&target_bp, &temp_bp)?; + symlink(&target_rp, &temp_rp)?; + try_symlink(config.get_data_path(), temp_data)?; }); measure_time!(profile_name, { From 737cf90a43960dc0240ea8cf0c4f6b24fd731916 Mon Sep 17 00:00:00 2001 From: ink0rr Date: Fri, 19 Jul 2024 13:05:42 +0700 Subject: [PATCH 2/3] chore: run clippy --- src/fs.rs | 8 ++++---- src/rgl/runner.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index 15153e3..983d484 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -118,19 +118,19 @@ pub fn set_modified_time(path: impl AsRef, time: SystemTime) -> Result<()> #[cfg(unix)] fn symlink_impl(from: &Path, to: &Path) -> io::Result<()> { use std::os::unix; - unix::fs::symlink(from, to) + unix::fs::symlink(canonicalize(from)?, to) } #[cfg(windows)] fn symlink_impl(from: &Path, to: &Path) -> io::Result<()> { use std::os::windows; - windows::fs::symlink_dir(from, to) + windows::fs::symlink_dir(canonicalize(from)?, to) } pub fn symlink(from: impl AsRef, to: impl AsRef) -> Result<()> { - let from = canonicalize(from)?; + let from = from.as_ref(); let to = to.as_ref(); - symlink_impl(&from, to).context(format!( + symlink_impl(from, to).context(format!( "Failed to create symlink\n\ >> From: {}\n\ >> To: {}", diff --git a/src/rgl/runner.rs b/src/rgl/runner.rs index 5a00bbd..a1c317e 100644 --- a/src/rgl/runner.rs +++ b/src/rgl/runner.rs @@ -30,8 +30,8 @@ pub fn run_or_watch(profile_name: &str, watch: bool, cached: bool) -> Result<()> copy_dir(rp, &target_rp)?; } empty_dir(&temp)?; - symlink(&target_bp, &temp_bp)?; - symlink(&target_rp, &temp_rp)?; + symlink(&target_bp, temp_bp)?; + symlink(&target_rp, temp_rp)?; try_symlink(config.get_data_path(), temp_data)?; }); From 8795db851950a5c78e551fc3078d942d00c21908 Mon Sep 17 00:00:00 2001 From: ink0rr Date: Fri, 19 Jul 2024 13:29:46 +0700 Subject: [PATCH 3/3] chore: bump version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f702b5c..f72357c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -745,7 +745,7 @@ dependencies = [ [[package]] name = "rgl" -version = "0.10.0" +version = "0.10.1" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 9c6e496..703e601 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rgl" -version = "0.10.0" +version = "0.10.1" edition = "2021" [[bin]]