Skip to content

Commit 9f2d5cf

Browse files
pietroalbiniMark-Simulacrum
authored andcommitted
use --if-match when an ETag is present
1 parent f87d28f commit 9f2d5cf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,14 @@ impl Context {
702702
// the logs is just confusing noise. Any authentication/permission error will be
703703
// encountered at the upload stage anyway.
704704
.stderr(Stdio::null()));
705-
let if_none_match = match get {
706-
Ok(output) => serde_json::from_slice::<GetResult>(&output.stdout)?.etag,
705+
let (conditional_header, conditional_value) = match get {
706+
Ok(output) => (
707+
"--if-match",
708+
serde_json::from_slice::<GetResult>(&output.stdout)?.etag,
709+
),
707710
// If the GET failed assume the file doesn't exist, and we need to upload a new one.
708711
// Setting the If-None-Match header to * will fail the request if the file exists.
709-
Err(_) => "*".to_string(),
712+
Err(_) => ("--if-none-match", "*".to_string()),
710713
};
711714

712715
let upload_addr = self
@@ -731,7 +734,7 @@ impl Context {
731734
.args(["--key", "manifests.txt"])
732735
// Fail the request if the manifest was already modified by something else (for
733736
// example, another release running in parallel).
734-
.args(["--if-none-match", &if_none_match]))?;
737+
.args([conditional_header, &conditional_value]))?;
735738

736739
Ok(())
737740
}

0 commit comments

Comments
 (0)