Skip to content

Commit

Permalink
fix: fvm rename fallback (#3689)
Browse files Browse the repository at this point in the history
fixes #3688
  • Loading branch information
digikata authored Nov 11, 2023
1 parent 0830f25 commit f923864
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
11 changes: 9 additions & 2 deletions crates/fluvio-version-manager/src/command/itself/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::env::current_exe;
use std::fs::{copy, write, create_dir_all};
use std::path::PathBuf;

use anyhow::{anyhow, Result};
use clap::Parser;
use anyhow::Result;

use crate::common::notify::Notify;
use crate::common::settings::Settings;
Expand Down Expand Up @@ -80,7 +80,14 @@ impl SelfInstallOpt {
}

// Copies "this" binary to the FVM binary directory
copy(current_binary_path, fvm_binary_path)?;
copy(current_binary_path.clone(), fvm_binary_path.clone()).map_err(|e| {
anyhow!(
"Couldn't copy fvm from {} to {} with error {}",
current_binary_path.display(),
fvm_binary_path.display(),
e
)
})?;
tracing::debug!(
?fvm_dir,
"Copied the FVM binary to the FVM home directory with success"
Expand Down
20 changes: 14 additions & 6 deletions crates/fluvio-version-manager/src/common/version_installer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use std::fs::{create_dir, rename};
use std::fs::{create_dir, copy, rename};

use anyhow::Result;
use anyhow::{anyhow, Result};
use tempfile::TempDir;

use fluvio_hub_util::fvm::{PackageSet, Download, Channel};
Expand Down Expand Up @@ -79,10 +79,18 @@ impl VersionInstaller {
}

for artif in package_set.artifacts.iter() {
rename(
tmp_dir.path().join(&artif.name),
version_path.join(&artif.name),
)?;
let src = tmp_dir.path().join(&artif.name);
let dst = version_path.join(&artif.name);
if rename(src.clone(), dst.clone()).is_err() {
copy(src.clone(), dst.clone()).map_err(|e| {
anyhow!(
"Error copying artifact {} to {}, {} ",
src.display(),
dst.display(),
e
)
})?;
}
}

Ok(version_path)
Expand Down

0 comments on commit f923864

Please sign in to comment.