Skip to content

Commit

Permalink
fix: remove uploadItem on report
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill committed Jan 31, 2024
1 parent daea26a commit e55f32d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
5 changes: 2 additions & 3 deletions pkg/storer/internal/upload/uploadstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,9 @@ func Report(
return fmt.Errorf("failed deleting chunk %s: %w", chunk.Address(), err)
}

ui.Synced = now().UnixNano()
err = batch.Put(ui)
err = batch.Delete(ui)
if err != nil {
return fmt.Errorf("failed updating uploadItem %s: %w", ui, err)
return fmt.Errorf("failed deleting uploadItem %s: %w", ui, err)
}

return batch.Commit()
Expand Down
18 changes: 5 additions & 13 deletions pkg/storer/internal/upload/uploadstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,28 +733,20 @@ func TestChunkReporter(t *testing.T) {
Address: chunk.Address(),
BatchID: chunk.Stamp().BatchID(),
}
err = ts.IndexStore().Get(ui)
has, err := ts.IndexStore().Has(ui)
if err != nil {
t.Fatalf("Get(...): unexpected error: %v", err)
t.Fatalf("unexpected error: %v", err)
}
wantUI := &upload.UploadItem{
Address: chunk.Address(),
BatchID: chunk.Stamp().BatchID(),
TagID: tag.TagID,
Uploaded: now().UnixNano(),
Synced: now().UnixNano(),
}

if diff := cmp.Diff(wantUI, ui); diff != "" {
t.Fatalf("Get(...): unexpected UploadItem (-want +have):\n%s", diff)
if has {
t.Fatalf("expected to not be found: %s", ui)
}

pi := &upload.PushItem{
Timestamp: now().UnixNano(),
Address: chunk.Address(),
BatchID: chunk.Stamp().BatchID(),
}
has, err := ts.IndexStore().Has(pi)
has, err = ts.IndexStore().Has(pi)
if err != nil {
t.Fatalf("Has(...): unexpected error: %v", err)
}
Expand Down

0 comments on commit e55f32d

Please sign in to comment.