Skip to content

Commit

Permalink
Wire ctx to getdag operations in gc.GC
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
  • Loading branch information
rht committed Jan 30, 2016
1 parent 89a6f01 commit fdba13a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pin/gc/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, pn pin.Pinner) (<-chan key.
bsrv := bserv.New(bs, offline.Exchange(bs))
ds := dag.NewDAGService(bsrv)

gcs, err := ColoredSet(pn, ds)
gcs, err := ColoredSet(ctx, pn, ds)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -69,16 +69,16 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, pn pin.Pinner) (<-chan key.
return output, nil
}

func Descendants(ds dag.DAGService, set key.KeySet, roots []key.Key) error {
func Descendants(ctx context.Context, ds dag.DAGService, set key.KeySet, roots []key.Key) error {
for _, k := range roots {
set.Add(k)
nd, err := ds.Get(context.Background(), k)
nd, err := ds.Get(ctx, k)
if err != nil {
return err
}

// EnumerateChildren recursively walks the dag and adds the keys to the given set
err = dag.EnumerateChildren(context.Background(), ds, nd, set)
err = dag.EnumerateChildren(ctx, ds, nd, set)
if err != nil {
return err
}
Expand All @@ -87,11 +87,11 @@ func Descendants(ds dag.DAGService, set key.KeySet, roots []key.Key) error {
return nil
}

func ColoredSet(pn pin.Pinner, ds dag.DAGService) (key.KeySet, error) {
func ColoredSet(ctx context.Context, pn pin.Pinner, ds dag.DAGService) (key.KeySet, error) {
// KeySet currently implemented in memory, in the future, may be bloom filter or
// disk backed to conserve memory.
gcs := key.NewKeySet()
err := Descendants(ds, gcs, pn.RecursiveKeys())
err := Descendants(ctx, ds, gcs, pn.RecursiveKeys())
if err != nil {
return nil, err
}
Expand All @@ -100,7 +100,7 @@ func ColoredSet(pn pin.Pinner, ds dag.DAGService) (key.KeySet, error) {
gcs.Add(k)
}

err = Descendants(ds, gcs, pn.InternalPins())
err = Descendants(ctx, ds, gcs, pn.InternalPins())
if err != nil {
return nil, err
}
Expand Down
8 changes: 7 additions & 1 deletion repo/fsrepo/fsrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,13 @@ func (r *FSRepo) GetStorageUsage() (uint64, error) {

var du uint64
err = filepath.Walk(pth, func(p string, f os.FileInfo, err error) error {
du += uint64(f.Size())
if err != nil {
log.Debugf("filepath.Walk error: %s", err)
return nil
}
if f != nil {
du += uint64(f.Size())
}
return nil
})
return du, err
Expand Down

0 comments on commit fdba13a

Please sign in to comment.