From a404e76cfe571c50cdbc1426cc5c47ddaeff2981 Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Sun, 7 Jun 2026 22:56:59 -1000 Subject: [PATCH] chore: remove defunct old queue package Remove old internal queue package that was only kept around to delete a previous installation's queue entries from the datastore. --- provider/internal/queue/queue.go | 66 -------------------------------- provider/reprovider.go | 13 ------- 2 files changed, 79 deletions(-) delete mode 100644 provider/internal/queue/queue.go diff --git a/provider/internal/queue/queue.go b/provider/internal/queue/queue.go deleted file mode 100644 index 96a33a7a4..000000000 --- a/provider/internal/queue/queue.go +++ /dev/null @@ -1,66 +0,0 @@ -// Package queue only remains to provide functionality to remove items from -// the old provider queue datastore. -// -// TODO: remove thos package after kubo v.39.0 -package queue - -import ( - "context" - "fmt" - - datastore "github.com/ipfs/go-datastore" - namespace "github.com/ipfs/go-datastore/namespace" - query "github.com/ipfs/go-datastore/query" -) - -// ClearDatastore clears any entries from the previous queue from the datastore. -func ClearDatastore(ds datastore.Batching) (int, error) { - const batchSize = 4096 - - ds = namespace.Wrap(ds, datastore.NewKey("/queue")) - ctx := context.Background() - - qry := query.Query{ - KeysOnly: true, - } - results, err := ds.Query(ctx, qry) - if err != nil { - return 0, fmt.Errorf("cannot query datastore: %w", err) - } - defer results.Close() - - batch, err := ds.Batch(ctx) - if err != nil { - return 0, fmt.Errorf("cannot create datastore batch: %w", err) - } - - var rmCount, writeCount int - for result := range results.Next() { - if ctx.Err() != nil { - return 0, ctx.Err() - } - if writeCount >= batchSize { - writeCount = 0 - if err = batch.Commit(ctx); err != nil { - return 0, fmt.Errorf("cannot commit datastore updates: %w", err) - } - } - if result.Error != nil { - return 0, fmt.Errorf("cannot read query result from datastore: %w", result.Error) - } - if err = batch.Delete(ctx, datastore.NewKey(result.Key)); err != nil { - return 0, fmt.Errorf("cannot delete key from datastore: %w", err) - } - rmCount++ - writeCount++ - } - - if err = batch.Commit(ctx); err != nil { - return 0, fmt.Errorf("cannot commit datastore updated: %w", err) - } - if err = ds.Sync(ctx, datastore.NewKey("")); err != nil { - return 0, fmt.Errorf("cannot sync datastore: %w", err) - } - - return rmCount, nil -} diff --git a/provider/reprovider.go b/provider/reprovider.go index fe98171a3..202fab78b 100644 --- a/provider/reprovider.go +++ b/provider/reprovider.go @@ -9,7 +9,6 @@ import ( "sync" "time" - oldqueue "github.com/ipfs/boxo/provider/internal/queue" "github.com/ipfs/boxo/verifcid" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" @@ -147,18 +146,6 @@ func New(ds datastore.Batching, opts ...Option) (System, error) { } s.ds = namespace.Wrap(ds, s.keyPrefix) - - // TODO: Remove this after kubo v0.39 is released. - // - // Remove any items from the old queue. - cleaned, err := oldqueue.ClearDatastore(s.ds) - if err != nil { - log.Error(err) - } - if cleaned != 0 { - log.Infof("removed %d cids from old provide queue", cleaned) - } - s.q = dsqueue.New(s.ds, "provide", dsqueue.WithDedupCacheSize(2048)) // This is after the options processing so we do not have to worry about leaking a context if there is an