mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
[yabridgectl] Recursively prune empty directories
If pruning results in a directory becoming empty, then we should remove that directory. This approach won't touch any directories that we aren't pruning from.
This commit is contained in:
@@ -96,6 +96,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
makes it easy to switch from the 64-bit version of a plugin to the 32-bit
|
||||
version, or from a 64-bit version of yabridge to the 32-bit version. I don't
|
||||
know why you would want to do either of those things, but now you can!
|
||||
- If pruning causes a directory to be empty, then the empty directory will be
|
||||
removed. This avoids having your plugin directories littered with empty
|
||||
directories.
|
||||
- Copies of `libyabridge-vst2.so` and `libyabridge-vst3.so` are now reflinked
|
||||
when supported by the file system. This speeds up the file coyping process
|
||||
while also reducing the amount of disk space used for yabridge when using
|
||||
|
||||
@@ -451,11 +451,10 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: Prune empty subdirectories
|
||||
for file in orphan_files {
|
||||
println!("- {}", file.path().display());
|
||||
if options.prune {
|
||||
match file {
|
||||
match &file {
|
||||
NativeFile::Regular(path) | NativeFile::Symlink(path) => {
|
||||
utils::remove_file(path)?;
|
||||
}
|
||||
@@ -463,6 +462,15 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
|
||||
utils::remove_dir_all(path)?;
|
||||
}
|
||||
}
|
||||
|
||||
// If the directory `file` was in is now empty, then we'll also recursively prune
|
||||
// the empty subdirectory
|
||||
let mut parent_dir = file.path().parent();
|
||||
while let Some(dir) =
|
||||
parent_dir.and_then(|dir| fs::remove_dir(dir).ok().map(|_| dir))
|
||||
{
|
||||
parent_dir = dir.parent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user