Fixup a cure case where a store path already exists so we never make a symlink (#414)

This commit is contained in:
Ana Hobden 2023-04-12 06:25:24 -07:00 committed by GitHub
parent 045fe5fc5d
commit b3c47227ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 17 deletions

View file

@ -93,8 +93,12 @@ impl Action for MoveUnpackedNix {
{
let entry_dest = dest_store.join(entry.file_name());
if entry_dest.exists() {
tracing::trace!(src = %entry.path().display(), dest = %entry_dest.display(), "Skipping, already exists");
} else {
tracing::trace!(src = %entry.path().display(), dest = %entry_dest.display(), "Removing already existing package");
tokio::fs::remove_dir_all(&entry_dest)
.await
.map_err(|e| ActionErrorKind::Remove(entry_dest.clone(), e))
.map_err(Self::error)?;
}
tracing::trace!(src = %entry.path().display(), dest = %entry_dest.display(), "Renaming");
tokio::fs::rename(&entry.path(), &entry_dest)
.await
@ -111,7 +115,6 @@ impl Action for MoveUnpackedNix {
})
.map_err(Self::error)?;
}
}
Ok(())
}

View file

@ -73,7 +73,7 @@ impl Action for SetupDefaultProfile {
let nix_pkg = if let Some(nix_pkg) = found_nix_pkg {
tokio::fs::read_link(&nix_pkg)
.await
.map_err(|e| ActionErrorKind::Canonicalize(nix_pkg, e))
.map_err(|e| ActionErrorKind::ReadSymlink(nix_pkg, e))
.map_err(Self::error)?
} else {
return Err(Self::error(SetupDefaultProfileError::NoNix));
@ -106,7 +106,7 @@ impl Action for SetupDefaultProfile {
let nss_ca_cert_pkg = if let Some(nss_ca_cert_pkg) = found_nss_ca_cert_pkg {
tokio::fs::read_link(&nss_ca_cert_pkg)
.await
.map_err(|e| ActionErrorKind::Canonicalize(nss_ca_cert_pkg, e))
.map_err(|e| ActionErrorKind::ReadSymlink(nss_ca_cert_pkg, e))
.map_err(Self::error)?
} else {
return Err(Self::error(SetupDefaultProfileError::NoNssCacert));