Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5b0e92f

Browse files
committedAug 13, 2015
run GC over internal blockstore as well
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent ec6a2a8 commit 5b0e92f

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed
 

‎core/corerepo/gc.go

+30-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,28 @@ func GarbageCollect(n *core.IpfsNode, ctx context.Context) error {
2121
return err
2222
}
2323

24+
internal, err := gc.GC(ctx, n.PrivBlocks, n.Pinning)
25+
if err != nil {
26+
return err
27+
}
28+
29+
var normalDone bool
30+
var internalDone bool
2431
for {
2532
select {
2633
case _, ok := <-rmed:
2734
if !ok {
28-
return nil
35+
if internalDone {
36+
return nil
37+
}
38+
normalDone = true
39+
}
40+
case _, ok := <-internal:
41+
if !ok {
42+
if normalDone {
43+
return nil
44+
}
45+
internalDone = true
2946
}
3047
case <-ctx.Done():
3148
return ctx.Err()
@@ -40,6 +57,11 @@ func GarbageCollectAsync(n *core.IpfsNode, ctx context.Context) (<-chan *KeyRemo
4057
return nil, err
4158
}
4259

60+
internal, err := gc.GC(ctx, n.PrivBlocks, n.Pinning)
61+
if err != nil {
62+
return nil, err
63+
}
64+
4365
out := make(chan *KeyRemoved)
4466
go func() {
4567
defer close(out)
@@ -50,6 +72,13 @@ func GarbageCollectAsync(n *core.IpfsNode, ctx context.Context) (<-chan *KeyRemo
5072
return
5173
}
5274
}
75+
for k := range internal {
76+
select {
77+
case out <- &KeyRemoved{k}:
78+
case <-ctx.Done():
79+
return
80+
}
81+
}
5382
}()
5483
return out, nil
5584
}

‎pin/gc/gc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, pn pin.Pinner) (<-chan key.
4242
return nil, err
4343
}
4444

45-
output := make(chan key.Key)
45+
output := make(chan key.Key, 16)
4646
go func() {
4747
defer close(output)
4848
for {

0 commit comments

Comments
 (0)
Please sign in to comment.