From e82dde9ac7b5ecf2b2b96ad38e5b22c8596de02f Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Tue, 23 Apr 2024 14:11:02 -0700 Subject: [PATCH] wip: debug logging to see why this still crosses devices --- magic-nix-cache/src/flakehub.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/magic-nix-cache/src/flakehub.rs b/magic-nix-cache/src/flakehub.rs index de4f2ee..0aa2ced 100644 --- a/magic-nix-cache/src/flakehub.rs +++ b/magic-nix-cache/src/flakehub.rs @@ -1,4 +1,5 @@ use crate::error::{Error, Result}; +use anyhow::Context; use attic::cache::CacheName; use attic::nix_store::{NixStore, StorePath}; use attic_client::push::{PushSession, PushSessionConfig}; @@ -295,9 +296,19 @@ async fn rewrite_github_actions_token( let new_netrc_contents = netrc_contents.replace(old_github_jwt, &new_github_jwt_string); // NOTE(cole-h): create the temporary file right next to the real one so we don't run into // cross-device linking issues when renaming + tracing::warn!("{:?}", &netrc_path); + tracing::warn!("{:?}", tokio::fs::metadata(&netrc_path).await); + tracing::warn!("{:?}", tokio::fs::symlink_metadata(&netrc_path).await); let netrc_path_tmp = netrc_path.with_extension("tmp"); - tokio::fs::write(&netrc_path_tmp, new_netrc_contents).await?; - tokio::fs::rename(&netrc_path_tmp, netrc_path).await?; + tracing::warn!("{:?}", &netrc_path_tmp); + tracing::warn!("{:?}", tokio::fs::metadata(&netrc_path_tmp).await); + tracing::warn!("{:?}", tokio::fs::symlink_metadata(&netrc_path_tmp).await); + tokio::fs::write(&netrc_path_tmp, new_netrc_contents) + .await + .with_context(|| format!("writing new JWT to {netrc_path_tmp:?}"))?; + tokio::fs::rename(&netrc_path_tmp, &netrc_path) + .await + .with_context(|| format!("renaming {netrc_path_tmp:?} to {netrc_path:?}"))?; Ok(new_github_jwt_string) }