From 64ac6d962cd3a1daba8e0536bef2bcc634d67f61 Mon Sep 17 00:00:00 2001 From: Stijn Seghers Date: Thu, 8 Dec 2022 15:49:46 +0100 Subject: [PATCH] fix(deployer): keep Cargo.lock between deployments --- 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 a76fe83c3..a6cefae80 100644 --- a/deployer/src/deployment/queue.rs +++ b/deployer/src/deployment/queue.rs @@ -238,7 +238,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; } @@ -381,6 +381,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 @@ -433,6 +438,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