removed unlink related functions
This commit is contained in:
@@ -33,18 +33,6 @@ impl Linker {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn remove_link(&self, to: &Path) -> Result<(), LinkerError> {
|
||||
let file = self.install_path().join(path_to_lowercase(to));
|
||||
let metadata = fs::symlink_metadata(&file)?;
|
||||
|
||||
if !metadata.file_type().is_symlink() {
|
||||
return Err(LinkerError::NotASymlink(file));
|
||||
}
|
||||
|
||||
fs::remove_file(&file)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn link_recursive(&self, from: &Path, to: &Path) -> Result<(), LinkerError> {
|
||||
for entry in fs::read_dir(from)? {
|
||||
let entry = entry?;
|
||||
@@ -64,30 +52,6 @@ impl Linker {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unlink_recursive(&self, from: &Path, to: &Path) -> Result<(), LinkerError> {
|
||||
for entry in fs::read_dir(from)? {
|
||||
let entry = entry?;
|
||||
let entry_path = entry.path();
|
||||
let relative = entry_path
|
||||
.strip_prefix(from)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
|
||||
let target_path = to.join(relative);
|
||||
|
||||
if entry_path.is_dir() {
|
||||
self.unlink_recursive(&entry_path, &target_path)?;
|
||||
|
||||
let install_target = self.install_path().join(&target_path);
|
||||
if install_target.exists() && fs::read_dir(&install_target)?.next().is_none() {
|
||||
fs::remove_dir(&install_target)?;
|
||||
}
|
||||
} else {
|
||||
self.remove_link(&target_path)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn link_plugin_files(
|
||||
&self,
|
||||
entries: &[FileTypeEnum],
|
||||
|
||||
Reference in New Issue
Block a user