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
e12adeca
Commit
e12adeca
authored
Jan 24, 2017
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use proper batching for filestore puts
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
2884c843
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
filestore/fsrefstore.go
filestore/fsrefstore.go
+17
-4
No files found.
filestore/fsrefstore.go
View file @
e12adeca
...
...
@@ -142,7 +142,15 @@ func (f *FileManager) Has(c *cid.Cid) (bool, error) {
return
f
.
ds
.
Has
(
dsk
)
}
type
putter
interface
{
Put
(
ds
.
Key
,
interface
{})
error
}
func
(
f
*
FileManager
)
Put
(
b
*
posinfo
.
FilestoreNode
)
error
{
return
f
.
putTo
(
b
,
f
.
ds
)
}
func
(
f
*
FileManager
)
putTo
(
b
*
posinfo
.
FilestoreNode
,
to
putter
)
error
{
var
dobj
pb
.
DataObj
if
!
filepath
.
HasPrefix
(
b
.
PosInfo
.
FullPath
,
f
.
root
)
{
...
...
@@ -163,15 +171,20 @@ func (f *FileManager) Put(b *posinfo.FilestoreNode) error {
return
err
}
return
f
.
ds
.
Put
(
dshelp
.
CidToDsKey
(
b
.
Cid
()),
data
)
return
to
.
Put
(
dshelp
.
CidToDsKey
(
b
.
Cid
()),
data
)
}
func
(
f
*
FileManager
)
PutMany
(
bs
[]
*
posinfo
.
FilestoreNode
)
error
{
// TODO: this better
batch
,
err
:=
f
.
ds
.
Batch
()
if
err
!=
nil
{
return
err
}
for
_
,
b
:=
range
bs
{
if
err
:=
f
.
P
ut
(
b
);
err
!=
nil
{
if
err
:=
f
.
p
ut
To
(
b
,
batch
);
err
!=
nil
{
return
err
}
}
return
nil
return
batch
.
Commit
()
}
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