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-pinner
Commits
ea997cce
Commit
ea997cce
authored
10 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flush!
parent
3d5b74c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
pin.go
pin.go
+27
-3
No files found.
pin.go
View file @
ea997cce
...
...
@@ -3,6 +3,8 @@ package pin
import
(
//ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
"bytes"
"encoding/json"
"sync"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
...
...
@@ -175,19 +177,41 @@ func LoadPinner(d ds.Datastore, dserv *mdag.DAGService) (Pinner, error) {
func
(
p
*
pinner
)
Flush
()
error
{
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
buf
:=
new
(
bytes
.
Buffer
)
enc
:=
json
.
NewEncoder
(
buf
)
recurse
:=
p
.
recursePin
.
GetKeys
()
err
:=
p
.
dstore
.
Put
(
recursePinDatastoreKey
,
recurse
)
err
:=
enc
.
Encode
(
recurse
)
if
err
!=
nil
{
return
err
}
err
=
p
.
dstore
.
Put
(
recursePinDatastoreKey
,
buf
.
Bytes
())
if
err
!=
nil
{
return
err
}
buf
=
new
(
bytes
.
Buffer
)
enc
=
json
.
NewEncoder
(
buf
)
direct
:=
p
.
directPin
.
GetKeys
()
err
=
p
.
dstore
.
Put
(
directPinDatastoreKey
,
direct
)
err
=
enc
.
Encode
(
direct
)
if
err
!=
nil
{
return
err
}
err
=
p
.
dstore
.
Put
(
directPinDatastoreKey
,
buf
.
Bytes
())
if
err
!=
nil
{
return
err
}
buf
=
new
(
bytes
.
Buffer
)
enc
=
json
.
NewEncoder
(
buf
)
err
=
enc
.
Encode
(
p
.
indirPin
.
refCounts
)
if
err
!=
nil
{
return
err
}
err
=
p
.
dstore
.
Put
(
indirectPinDatastoreKey
,
p
.
indirPin
.
refCounts
)
err
=
p
.
dstore
.
Put
(
indirectPinDatastoreKey
,
buf
.
Bytes
()
)
if
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
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