From 24657bc2e5fc8e1a1de9744b239b9ddf4938ed8c Mon Sep 17 00:00:00 2001 From: "Stijn (\"stain\") Seghers" Date: Wed, 14 Dec 2022 11:15:52 +0100 Subject: [PATCH] fix(deployer): keep Cargo.lock between deployments (#517) --- deployer/src/deployment/queue.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/deployer/src/deployment/queue.rs b/deployer/src/deployment/queue.rs index f8eac840a..79f517b1e 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -282,7 +282,7 @@ async fn extract_tar_gz_data(data: impl Read, dest: impl AsRef) -> Result< let mut entries = fs::read_dir(&dest).await?; while let Some(entry) = entries.next_entry().await? { // Ignore the build cache directory - if entry.file_name() == "target" { + if ["target", "Cargo.lock"].contains(&entry.file_name().to_string_lossy().as_ref()) { continue; } @@ -433,6 +433,11 @@ mod tests { .await .unwrap(); + // Cargo.lock file shouldn't be deleted + fs::write(p.join("Cargo.lock"), "lock file contents shouldn't matter") + .await + .unwrap(); + // Binary data for an archive in the following form: // // - temp @@ -485,6 +490,12 @@ ff0e55bda1ff01000000000000000000e0079c01ff12a55500280000", "build cache file should not be touched" ); + assert_eq!( + fs::read_to_string(p.join("Cargo.lock")).await.unwrap(), + "lock file contents shouldn't matter", + "Cargo lock file should not be touched" + ); + // Can we extract again without error? super::extract_tar_gz_data(test_data.as_slice(), &p) .await