Skip to content

Commit

Permalink
Fix broken MD5 hash cache.
Browse files Browse the repository at this point in the history
This change fixes issues causing no matches to occur for existing
objects at S3 in some cases. This issue caused all versions of a
package in a repo to be uploaded again to S3.

Lookups in the cache of file MD5s were failing as the key in the map
had its prefix stripped while the key used for the lookup did not have
the prefix stripped. This change stops stripping the prefix when
building the cache.

Retrieving object MD5s from object metadata (as opposed to the etag
that comes with the object list) were failing as the key in the
metadata map is now "md5" (all lowercase) vs. "Md5" that was used
pre-v2 AWS SDK.
  • Loading branch information
Kevin Martin authored and neolynx committed Oct 1, 2024
1 parent 87fc8c1 commit 641e2ff
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions s3/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (storage *PublishedStorage) getMD5(path string) (string, error) {
return "", err
}

return output.Metadata["Md5"], nil
return output.Metadata["md5"], nil
}

// putFile uploads file-like object to
Expand Down Expand Up @@ -431,11 +431,7 @@ func (storage *PublishedStorage) internalFilelist(prefix string, hidePlusWorkaro
continue
}

if prefix == "" {
paths = append(paths, *key.Key)
} else {
paths = append(paths, (*key.Key)[len(prefix):])
}
paths = append(paths, *key.Key)
md5s = append(md5s, strings.Replace(*key.ETag, "\"", "", -1))
}
}
Expand Down

0 comments on commit 641e2ff

Please sign in to comment.