Skip to content

Commit

Permalink
Merge pull request #25 from ink0rr/dev
Browse files Browse the repository at this point in the history
rgl v0.10.1
  • Loading branch information
ink0rr authored Jul 19, 2024
2 parents 5119240 + 8795db8 commit 5a34a4f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rgl"
version = "0.10.0"
version = "0.10.1"
edition = "2021"

[[bin]]
Expand Down
8 changes: 4 additions & 4 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ pub fn set_modified_time(path: impl AsRef<Path>, 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<Path>, to: impl AsRef<Path>) -> 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\
<yellow> >></> From: {}\n\
<yellow> >></> To: {}",
Expand Down
24 changes: 5 additions & 19 deletions src/rgl/runner.rs
Original file line number Diff line number Diff line change
@@ -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<()> {
Expand All @@ -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, {
Expand Down

0 comments on commit 5a34a4f

Please sign in to comment.