Fix more ineffassign warnings.
[arvados.git] / services / keep-balance / collection.go
index 534928bc82340bb23574f71ceac85c7872d8deb0..1659918cafe20c62162abfb1e841a40f80170c0a 100644 (file)
@@ -5,10 +5,11 @@
 package main
 
 import (
+       "context"
        "fmt"
        "time"
 
-       "git.curoverse.com/arvados.git/sdk/go/arvados"
+       "git.arvados.org/arvados.git/sdk/go/arvados"
 )
 
 func countCollections(c *arvados.Client, params arvados.ResourceListParams) (int, error) {
@@ -30,7 +31,7 @@ func countCollections(c *arvados.Client, params arvados.ResourceListParams) (int
 //
 // If pageSize > 0 it is used as the maximum page size in each API
 // call; otherwise the maximum allowed page size is requested.
-func EachCollection(c *arvados.Client, pageSize int, f func(arvados.Collection) error, progress func(done, total int)) error {
+func EachCollection(ctx context.Context, c *arvados.Client, pageSize int, f func(arvados.Collection) error, progress func(done, total int)) error {
        if progress == nil {
                progress = func(_, _ int) {}
        }
@@ -75,12 +76,12 @@ func EachCollection(c *arvados.Client, pageSize int, f func(arvados.Collection)
        for {
                progress(callCount, expectCount)
                var page arvados.CollectionList
-               err := c.RequestAndDecode(&page, "GET", "arvados/v1/collections", nil, params)
+               err := c.RequestAndDecodeContext(ctx, &page, "GET", "arvados/v1/collections", nil, params)
                if err != nil {
                        return err
                }
                for _, coll := range page.Items {
-                       if last.ModifiedAt != nil && *last.ModifiedAt == *coll.ModifiedAt && last.UUID >= coll.UUID {
+                       if last.ModifiedAt == coll.ModifiedAt && last.UUID >= coll.UUID {
                                continue
                        }
                        callCount++
@@ -92,9 +93,9 @@ func EachCollection(c *arvados.Client, pageSize int, f func(arvados.Collection)
                }
                if len(page.Items) == 0 && !gettingExactTimestamp {
                        break
-               } else if last.ModifiedAt == nil {
+               } else if last.ModifiedAt.IsZero() {
                        return fmt.Errorf("BUG: Last collection on the page (%s) has no modified_at timestamp; cannot make progress", last.UUID)
-               } else if len(page.Items) > 0 && *last.ModifiedAt == filterTime {
+               } else if len(page.Items) > 0 && last.ModifiedAt == filterTime {
                        // If we requested time>=X and never got a
                        // time>X then we might not have received all
                        // items with time==X yet. Switch to
@@ -135,7 +136,7 @@ func EachCollection(c *arvados.Client, pageSize int, f func(arvados.Collection)
                        // avoiding that would add overhead in the
                        // overwhelmingly common cases, so we don't
                        // bother.
-                       filterTime = *last.ModifiedAt
+                       filterTime = last.ModifiedAt
                        params.Filters = []arvados.Filter{{
                                Attr:     "modified_at",
                                Operator: ">=",