fix: name too long error for head/delete

This commit is contained in:
Ben McClelland
2024-09-20 09:17:19 -07:00
parent 20d65ea6d9
commit 0d0de244e1
2 changed files with 14 additions and 2 deletions
+9
View File
@@ -2155,6 +2155,9 @@ func (p *Posix) DeleteObject(ctx context.Context, input *s3.DeleteObjectInput) (
if getString(input.VersionId) == "" {
// if the versionId is not specified, make the current version a delete marker
fi, err := os.Stat(objpath)
if errors.Is(err, syscall.ENAMETOOLONG) {
return nil, s3err.GetAPIError(s3err.ErrKeyTooLong)
}
if err != nil {
return nil, s3err.GetAPIError(s3err.ErrNoSuchKey)
}
@@ -2282,6 +2285,9 @@ func (p *Posix) DeleteObject(ctx context.Context, input *s3.DeleteObjectInput) (
isDelMarker, _ := p.isObjDeleteMarker(versionPath, *input.VersionId)
err = os.Remove(filepath.Join(versionPath, *input.VersionId))
if errors.Is(err, syscall.ENAMETOOLONG) {
return nil, s3err.GetAPIError(s3err.ErrKeyTooLong)
}
if errors.Is(err, fs.ErrNotExist) {
return &s3.DeleteObjectOutput{
DeleteMarker: &isDelMarker,
@@ -2300,6 +2306,9 @@ func (p *Posix) DeleteObject(ctx context.Context, input *s3.DeleteObjectInput) (
}
fi, err := os.Stat(objpath)
if errors.Is(err, syscall.ENAMETOOLONG) {
return nil, s3err.GetAPIError(s3err.ErrKeyTooLong)
}
if errors.Is(err, fs.ErrNotExist) {
// AWS returns success if the object does not exist
return &s3.DeleteObjectOutput{}, nil
+5 -2
View File
@@ -10186,7 +10186,7 @@ func HeadObject_name_too_long(s *S3Conf) error {
Key: getPtr(genRandString(300)),
})
cancel()
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrMalformedXML)); err != nil {
if err := checkSdkApiErr(err, "BadRequest"); err != nil {
return err
}
@@ -10487,7 +10487,10 @@ func DeleteObject_name_too_long(s *S3Conf) error {
Key: getPtr(genRandString(300)),
})
cancel()
return err
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrKeyTooLong)); err != nil {
return err
}
return nil
})
}