feat(etag): include mtime in file ETag formula

This commit is contained in:
Edouard Vanbelle
2026-06-06 16:46:19 +02:00
parent 0135930da9
commit c91515cb65
3 changed files with 74 additions and 39 deletions
+6 -7
View File
@@ -79,13 +79,12 @@ pub struct FileDto {
impl From<File> for FileDto {
fn from(file: File) -> Self {
// Compute the HTTP ETag BEFORE consuming the entity — once
// `File::etag()` folds modified_at (and possibly more) into
// the formula, this becomes more than a string clone and
// must run against a live entity, not against
// already-extracted parts. content_hash is just the blob
// hash; etag is the cache token derived from it.
let etag = file.etag().to_string();
// Compute the HTTP ETag BEFORE consuming the entity —
// `File::etag()` derives from `blob_hash` + `modified_at`,
// so it must run against the live entity, not against
// already-extracted parts. `content_hash` is just the raw
// blob hash; `etag` is the cache token derived from it.
let etag = file.etag();
let content_hash = file.content_hash().to_string();
// Consume the entity by moving all fields — zero heap allocations