Skip to content

Commit 2195a7a

Browse files
committed
fix logic
1 parent 7e64a78 commit 2195a7a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rollup/internal/orm/blob_upload.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (*BlobUpload) TableName() string {
4242
func (o *BlobUpload) GetFirstUnuploadedBatchIndexByPlatform(ctx context.Context, startBatch uint64, platform types.BlobStoragePlatform) (uint64, error) {
4343
db := o.db.WithContext(ctx)
4444
db = db.Model(&BlobUpload{})
45-
db = db.Where("platform = ? AND status = ?", platform, types.BlobUploadStatusUploaded)
45+
db = db.Where("platform = ? AND status = ? AND deleted_at IS NULL", platform, types.BlobUploadStatusUploaded)
4646
db = db.Order("batch_index DESC")
4747
db = db.Limit(1)
4848

@@ -103,6 +103,7 @@ func (o *BlobUpload) InsertOrUpdateBlobUpload(ctx context.Context, batchIndex ui
103103
}
104104
if err := db.Clauses(clause.OnConflict{
105105
Columns: []clause.Column{{Name: "batch_index"}, {Name: "batch_hash"}, {Name: "platform"}},
106+
Where: clause.Where{Exprs: []clause.Expression{clause.Eq{Column: "deleted_at", Value: nil}}},
106107
DoUpdates: clause.AssignmentColumns([]string{"status"}),
107108
}).Create(blobUpload).Error; err != nil {
108109
return fmt.Errorf("BlobUpload.InsertOrUpdateBlobUpload error: %w, batch index: %v, platform: %v", err, batchIndex, platform)

0 commit comments

Comments
 (0)