可靠性: 完善 R2 备份恢复与对象生命周期

This commit is contained in:
tamakyi
2026-11-05 08:41:55 +08:00
parent 3e7719f200
commit 937e688cfa
32 changed files with 4151 additions and 231 deletions
+4 -1
View File
@@ -871,7 +871,7 @@ func uploadImage(ctx context.Context, opts uploadImageOptions) error {
if err != nil {
return errors.Wrap(err, "get S3 client")
}
if _, err := client.PutObject(ctx.Request().Context(), &s3.PutObjectInput{
if err := storage.PutObject(ctx.Request().Context(), client, &s3.PutObjectInput{
Bucket: aws.String(conf.Upload.ImageBucket),
Key: aws.String(uploadKey),
Body: bytes.NewReader(uploadData),
@@ -894,6 +894,9 @@ func uploadImage(ctx context.Context, opts uploadImageOptions) error {
IsDeletingPrevious: opts.IsDeletingPrevious,
})
if err != nil {
if enqueueErr := db.R2DeleteTasks.Enqueue(ctx.Request().Context(), conf.Upload.ImageBucket, []string{uploadKey}); enqueueErr != nil {
return errors.Wrapf(enqueueErr, "compensate upload image after metadata failure: %v", err)
}
return errors.Wrap(err, "create upload image")
}
return nil