diff --git a/src/Backups/BackupIO_S3.cpp b/src/Backups/BackupIO_S3.cpp index e474fabf232..f2f0a2ef5e3 100644 --- a/src/Backups/BackupIO_S3.cpp +++ b/src/Backups/BackupIO_S3.cpp @@ -80,6 +80,12 @@ namespace throw Exception(outcome.GetError().GetMessage(), ErrorCodes::S3_ERROR); return outcome.GetResult().GetContents(); } + + bool isNotFoundError(Aws::S3::S3Errors error) + { + return error == Aws::S3::S3Errors::RESOURCE_NOT_FOUND + || error == Aws::S3::S3Errors::NO_SUCH_KEY; + } } @@ -370,7 +376,7 @@ void BackupWriterS3::removeFile(const String & file_name) request.SetBucket(s3_uri.bucket); request.SetKey(fs::path(s3_uri.key) / file_name); auto outcome = client->DeleteObject(request); - if (!outcome.IsSuccess()) + if (!outcome.IsSuccess() && !isNotFoundError(outcome.GetError().GetErrorType())) throw Exception(outcome.GetError().GetMessage(), ErrorCodes::S3_ERROR); } @@ -428,7 +434,7 @@ void BackupWriterS3::removeFilesBatch(const Strings & file_names) request.SetDelete(delkeys); auto outcome = client->DeleteObjects(request); - if (!outcome.IsSuccess()) + if (!outcome.IsSuccess() && !isNotFoundError(outcome.GetError().GetErrorType())) throw Exception(outcome.GetError().GetMessage(), ErrorCodes::S3_ERROR); } }