0
0
mirror of https://github.com/thegeeklab/wp-s3-action.git synced 2024-09-07 19:02:14 +02:00

fix: ensure uploads on 404 NotFound errors (#125)

This commit is contained in:
Robert Kaussow 2024-06-08 12:39:21 +02:00 committed by GitHub
parent 88504616e3
commit 5bb291acf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View File

@ -71,8 +71,8 @@ func (u *S3) Upload(ctx context.Context, opt S3UploadOptions) error {
Key: &opt.RemoteObjectKey,
})
if err != nil {
var noSuchKeyError *types.NoSuchKey
if !errors.As(err, &noSuchKeyError) {
var notFoundErr *types.NotFound
if !errors.As(err, &notFoundErr) {
return err
}

View File

@ -68,7 +68,7 @@ func TestS3_Upload(t *testing.T) {
t.Helper()
mockS3Client := mocks.NewMockS3APIClient(t)
mockS3Client.On("HeadObject", mock.Anything, mock.Anything).Return(&s3.HeadObjectOutput{}, &types.NoSuchKey{})
mockS3Client.On("HeadObject", mock.Anything, mock.Anything).Return(&s3.HeadObjectOutput{}, &types.NotFound{})
mockS3Client.On("PutObject", mock.Anything, mock.Anything).Return(&s3.PutObjectOutput{}, nil)
return &S3{
@ -227,7 +227,7 @@ func TestS3_Upload(t *testing.T) {
t.Helper()
mockS3Client := mocks.NewMockS3APIClient(t)
mockS3Client.On("HeadObject", mock.Anything, mock.Anything).Return(&s3.HeadObjectOutput{}, &types.NoSuchKey{})
mockS3Client.On("HeadObject", mock.Anything, mock.Anything).Return(&s3.HeadObjectOutput{}, &types.NotFound{})
return &S3{
client: mockS3Client,

View File

@ -76,7 +76,7 @@ func (p *Plugin) Execute() error {
}
if err := p.runJobs(p.Network.Context, client); err != nil {
return fmt.Errorf("error while creating sync job: %w", err)
return fmt.Errorf("error while running jobs: %w", err)
}
return nil