Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
fdba13a3
Commit
fdba13a3
authored
Jan 21, 2016
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wire ctx to getdag operations in gc.GC
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
89a6f01b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
pin/gc/gc.go
pin/gc/gc.go
+7
-7
repo/fsrepo/fsrepo.go
repo/fsrepo/fsrepo.go
+7
-1
No files found.
pin/gc/gc.go
View file @
fdba13a3
...
...
@@ -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
}
...
...
@@ -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
(
c
ontext
.
Background
()
,
k
)
nd
,
err
:=
ds
.
Get
(
c
tx
,
k
)
if
err
!=
nil
{
return
err
}
// EnumerateChildren recursively walks the dag and adds the keys to the given set
err
=
dag
.
EnumerateChildren
(
c
ontext
.
Background
()
,
ds
,
nd
,
set
)
err
=
dag
.
EnumerateChildren
(
c
tx
,
ds
,
nd
,
set
)
if
err
!=
nil
{
return
err
}
...
...
@@ -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
}
...
...
@@ -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
}
...
...
repo/fsrepo/fsrepo.go
View file @
fdba13a3
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment