Fixup a cure case where a store path already exists so we never make a symlink (#414)
This commit is contained in:
parent
045fe5fc5d
commit
b3c47227ff
|
@ -93,24 +93,27 @@ 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(), "Renaming");
|
||||
tokio::fs::rename(&entry.path(), &entry_dest)
|
||||
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::Rename(entry.path().clone(), entry_dest.to_owned(), e)
|
||||
})
|
||||
.map_err(Self::error)?;
|
||||
// Leave a back link where we copied from since later we may need to know which packages we actually transferred
|
||||
// eg, know which `nix` version we installed when curing a user with several versions installed
|
||||
tokio::fs::symlink(&entry_dest, entry.path())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
ActionErrorKind::Symlink(entry_dest.to_owned(), entry.path().clone(), e)
|
||||
})
|
||||
.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
|
||||
.map_err(|e| {
|
||||
ActionErrorKind::Rename(entry.path().clone(), entry_dest.to_owned(), e)
|
||||
})
|
||||
.map_err(Self::error)?;
|
||||
// Leave a back link where we copied from since later we may need to know which packages we actually transferred
|
||||
// eg, know which `nix` version we installed when curing a user with several versions installed
|
||||
tokio::fs::symlink(&entry_dest, entry.path())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
ActionErrorKind::Symlink(entry_dest.to_owned(), entry.path().clone(), e)
|
||||
})
|
||||
.map_err(Self::error)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue