mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
S3 FileExists fix
According to https://tools.ietf.org/html/rfc7231#section-4.3.2 HEAD must not have response body so the AWS error code NoSuchKey cannot be received from S3 and we need to fallback to HTTP NotFound error code.
This commit is contained in:
@@ -20,6 +20,8 @@ import (
|
||||
"github.com/smira/go-aws-auth"
|
||||
)
|
||||
|
||||
const errCodeNotFound = "NotFound"
|
||||
|
||||
// PublishedStorage abstract file system with published files (actually hosted on S3)
|
||||
type PublishedStorage struct {
|
||||
s3 *s3.S3
|
||||
@@ -429,7 +431,7 @@ func (storage *PublishedStorage) FileExists(path string) (bool, error) {
|
||||
_, err := storage.s3.HeadObject(params)
|
||||
if err != nil {
|
||||
aerr, ok := err.(awserr.Error)
|
||||
if ok && aerr.Code() == s3.ErrCodeNoSuchKey {
|
||||
if ok && aerr.Code() == errCodeNotFound {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user