Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ mod tests {
location: Path::from("test"),
last_modified: Utc.timestamp_nanos(100),
size: 100,
e_tag: Some("123".to_string()),
e_tag: Some("\"123\"".to_string()),
version: None,
};

Expand Down Expand Up @@ -2521,16 +2521,16 @@ mod tests {

options = GetOptions::default();

options.if_match = Some("123".to_string());
options.if_match = Some("\"123\"".to_string());
options.check_preconditions(&meta).unwrap();

options.if_match = Some("123,354".to_string());
options.if_match = Some("\"123\",\"354\"".to_string());
options.check_preconditions(&meta).unwrap();

options.if_match = Some("354, 123,".to_string());
options.if_match = Some("\"354\", \"123\"".to_string());
options.check_preconditions(&meta).unwrap();

options.if_match = Some("354".to_string());
options.if_match = Some("\"354\"".to_string());
options.check_preconditions(&meta).unwrap_err();

options.if_match = Some("*".to_string());
Expand All @@ -2542,16 +2542,16 @@ mod tests {

options = GetOptions::default();

options.if_none_match = Some("123".to_string());
options.if_none_match = Some("\"123\"".to_string());
options.check_preconditions(&meta).unwrap_err();

options.if_none_match = Some("*".to_string());
options.check_preconditions(&meta).unwrap_err();

options.if_none_match = Some("1232".to_string());
options.if_none_match = Some("\"1232\"".to_string());
options.check_preconditions(&meta).unwrap();

options.if_none_match = Some("23, 123".to_string());
options.if_none_match = Some("\"23\", \"123\"".to_string());
options.check_preconditions(&meta).unwrap_err();

// If-None-Match takes precedence
Expand Down
2 changes: 1 addition & 1 deletion src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ fn get_etag(metadata: &Metadata) -> String {
// Use an ETag scheme based on that used by many popular HTTP servers
// <https://httpd.apache.org/docs/2.2/mod/core.html#fileetag>
// <https://stackoverflow.com/questions/47512043/how-etags-are-generated-and-configured>
format!("{inode:x}-{mtime:x}-{size:x}")
format!("\"{inode:x}-{mtime:x}-{size:x}\"")
}

fn convert_metadata(metadata: Metadata, location: Path) -> ObjectMeta {
Expand Down
14 changes: 7 additions & 7 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl Storage {
source: format!("Object at location {location} not found").into(),
}),
Some(e) => {
let existing = e.e_tag.to_string();
let existing = format!("\"{}\"", e.e_tag);
let expected = v.e_tag.ok_or(Error::MissingETag)?;
if existing == expected {
*e = entry;
Expand Down Expand Up @@ -217,7 +217,7 @@ impl ObjectStore for InMemory {
storage.next_etag += 1;

Ok(PutResult {
e_tag: Some(etag.to_string()),
e_tag: Some(format!("\"{}\"", etag)),
version: None,
extensions: Default::default(),
})
Expand All @@ -238,7 +238,7 @@ impl ObjectStore for InMemory {

async fn get_opts(&self, location: &Path, options: GetOptions) -> Result<GetResult> {
let entry = self.entry(location)?;
let e_tag = entry.e_tag.to_string();
let e_tag = format!("\"{}\"", entry.e_tag);

let meta = ObjectMeta {
location: location.clone(),
Expand Down Expand Up @@ -331,7 +331,7 @@ impl ObjectStore for InMemory {
location: key.clone(),
last_modified: value.last_modified,
size: value.data.len() as u64,
e_tag: Some(value.e_tag.to_string()),
e_tag: Some(format!("\"{}\"", value.e_tag)),
version: None,
})
})
Expand Down Expand Up @@ -376,7 +376,7 @@ impl ObjectStore for InMemory {
location: k.clone(),
last_modified: v.last_modified,
size: v.data.len() as u64,
e_tag: Some(v.e_tag.to_string()),
e_tag: Some(format!("\"{}\"", v.e_tag)),
version: None,
};
objects.push(object);
Expand Down Expand Up @@ -480,7 +480,7 @@ impl MultipartStore for InMemory {
}
let etag = storage.insert(path, buf.into(), upload.attributes);
Ok(PutResult {
e_tag: Some(etag.to_string()),
e_tag: Some(format!("\"{}\"", etag)),
version: None,
extensions: Default::default(),
})
Expand Down Expand Up @@ -547,7 +547,7 @@ impl MultipartUpload for InMemoryUpload {
);

Ok(PutResult {
e_tag: Some(etag.to_string()),
e_tag: Some(format!("\"{}\"", etag)),
version: None,
extensions: Default::default(),
})
Expand Down