Skip to content

Commit e6b84a2

Browse files
committed
fix logic
1 parent b255336 commit e6b84a2

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

rollup/internal/controller/blob_uploader/blob_uploader.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,24 @@ func (b *BlobUploader) GetFirstUnuploadedBatchByPlatform(ctx context.Context, st
219219

220220
// to check if the parent batch uploaded
221221
// if no, there is a batch revert happened, we need to fallback to upload previous batch
222-
fields := map[string]interface{}{
223-
"batch_index = ?": batchIndex - 1,
224-
"batch_hash = ?": batch.ParentBatchHash,
225-
"platform = ?": int16(platform),
226-
"status = ?": int16(types.BlobUploadStatusUploaded),
227-
}
228-
blobUpload, err := b.blobUploadOrm.GetBlobUploads(ctx, fields, nil, 1)
229-
if err != nil {
230-
return nil, err
222+
if batchIndex > 0 {
223+
fields := map[string]interface{}{
224+
"batch_index = ?": batchIndex - 1,
225+
"batch_hash = ?": batch.ParentBatchHash,
226+
"platform = ?": platform,
227+
"status = ?": types.BlobUploadStatusUploaded,
228+
}
229+
blobUpload, err := b.blobUploadOrm.GetBlobUploads(ctx, fields, nil, 1)
230+
if err != nil {
231+
return nil, err
232+
}
233+
234+
if len(blobUpload) == 0 {
235+
batchIndex--
236+
continue
237+
}
231238
}
232239

233-
if len(blobUpload) == 0 {
234-
batchIndex--
235-
continue
236-
}
237240
break
238241
}
239242

rollup/internal/orm/blob_upload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (*BlobUpload) TableName() string {
3838
return "blob_upload"
3939
}
4040

41-
// GetFirstUnuploadedBatchIndexByPlatform retrieves the first batch index that either hasn't been uploaded to corresponding blob storage service
41+
// GetFirstUnuploadedBatchIndexByPlatform retrieves the first batch index that hasn't been uploaded to corresponding blob storage service
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{})

0 commit comments

Comments
 (0)