mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Fix broken symlinks not being removed
`Path::exists()` returns false for broken symlinks: https://doc.rust-lang.org/std/path/struct.Path.html#method.exists
This commit is contained in:
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic
|
and this project adheres to [Semantic
|
||||||
Versioning](https://semver.org/spec/v2.0.0.html).
|
Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
### yabridgectl
|
||||||
|
|
||||||
|
- Fixed issue with overwriting broken symlinks during `yabridgectl sync`.
|
||||||
|
|
||||||
## [1.4.0] - 2020-07-26
|
## [1.4.0] - 2020-07-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::config::{Config, InstallationMethod};
|
use crate::config::{Config, InstallationMethod};
|
||||||
@@ -173,9 +174,10 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
|
|||||||
}
|
}
|
||||||
for plugin in search_results.vst2_files {
|
for plugin in search_results.vst2_files {
|
||||||
// If the target file already exists, we'll remove it first to prevent issues with
|
// If the target file already exists, we'll remove it first to prevent issues with
|
||||||
// mixing symlinks and regular files
|
// mixing symlinks and regular files. We check `std::fs::symlink_metadata` instead of
|
||||||
|
// `Path::exists()` because the latter reports false for broken symlinks.
|
||||||
let target_path = plugin.with_extension("so");
|
let target_path = plugin.with_extension("so");
|
||||||
if target_path.exists() {
|
if fs::symlink_metadata(&target_path).is_ok() {
|
||||||
utils::remove_file(&target_path)?;
|
utils::remove_file(&target_path)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user