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
5bfb8867
Commit
5bfb8867
authored
Nov 04, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load static plugins in init
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
c154f7f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
23 deletions
+31
-23
cmd/ipfs/main.go
cmd/ipfs/main.go
+5
-4
plugin/loader/load.go
plugin/loader/load.go
+15
-13
repo/fsrepo/config_test.go
repo/fsrepo/config_test.go
+11
-6
No files found.
cmd/ipfs/main.go
View file @
5bfb8867
...
...
@@ -174,10 +174,11 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
if
err
!=
nil
{
return
nil
,
err
}
if
ok
{
if
_
,
err
:=
loader
.
LoadPlugins
(
pluginpath
);
err
!=
nil
{
log
.
Error
(
"error loading plugins: "
,
err
)
}
if
!
ok
{
pluginpath
=
""
}
if
_
,
err
:=
loader
.
LoadPlugins
(
pluginpath
);
err
!=
nil
{
log
.
Error
(
"error loading plugins: "
,
err
)
}
exctr
=
cmds
.
NewExecutor
(
req
.
Root
)
...
...
plugin/loader/load.go
View file @
5bfb8867
...
...
@@ -22,20 +22,22 @@ func LoadPlugins(pluginDir string) ([]plugin.Plugin, error) {
plMap
[
v
.
Name
()]
=
v
}
newPls
,
err
:=
loadDynamicPlugins
(
pluginDir
)
if
err
!=
nil
{
return
nil
,
err
}
if
pluginDir
!=
""
{
newPls
,
err
:=
loadDynamicPlugins
(
pluginDir
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
pl
:=
range
newPls
{
if
ppl
,
ok
:=
plMap
[
pl
.
Name
()];
ok
{
// plugin is already preloaded
return
nil
,
fmt
.
Errorf
(
"plugin: %s, is duplicated in version: %s, "
+
"while trying to load dynamically: %s"
,
ppl
.
Name
(),
ppl
.
Version
(),
pl
.
Version
())
for
_
,
pl
:=
range
newPls
{
if
ppl
,
ok
:=
plMap
[
pl
.
Name
()];
ok
{
// plugin is already preloaded
return
nil
,
fmt
.
Errorf
(
"plugin: %s, is duplicated in version: %s, "
+
"while trying to load dynamically: %s"
,
ppl
.
Name
(),
ppl
.
Version
(),
pl
.
Version
())
}
plMap
[
pl
.
Name
()]
=
pl
}
plMap
[
pl
.
Name
()]
=
pl
}
pls
:=
make
([]
plugin
.
Plugin
,
0
,
len
(
plMap
))
...
...
@@ -43,7 +45,7 @@ func LoadPlugins(pluginDir string) ([]plugin.Plugin, error) {
pls
=
append
(
pls
,
v
)
}
err
=
initialize
(
pls
)
err
:
=
initialize
(
pls
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
repo/fsrepo/config_test.go
View file @
5bfb8867
package
fsrepo
package
fsrepo
_test
import
(
"encoding/json"
...
...
@@ -7,7 +7,10 @@ import (
"reflect"
"testing"
config
"gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config"
"github.com/ipfs/go-ipfs/plugin/loader"
"github.com/ipfs/go-ipfs/repo/fsrepo"
"gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config"
)
// note: to test sorting of the mountpoints in the disk spec they are
...
...
@@ -72,6 +75,8 @@ var measureConfig = []byte(`{
}`
)
func
TestDefaultDatastoreConfig
(
t
*
testing
.
T
)
{
loader
.
LoadPlugins
(
""
)
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"ipfs-datastore-config-test"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -84,7 +89,7 @@ func TestDefaultDatastoreConfig(t *testing.T) {
t
.
Fatal
(
err
)
}
dsc
,
err
:=
AnyDatastoreConfig
(
config
.
Spec
)
dsc
,
err
:=
fsrepo
.
AnyDatastoreConfig
(
config
.
Spec
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -122,7 +127,7 @@ func TestLevelDbConfig(t *testing.T) {
t
.
Fatal
(
err
)
}
dsc
,
err
:=
AnyDatastoreConfig
(
spec
)
dsc
,
err
:=
fsrepo
.
AnyDatastoreConfig
(
spec
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -160,7 +165,7 @@ func TestFlatfsConfig(t *testing.T) {
t
.
Fatal
(
err
)
}
dsc
,
err
:=
AnyDatastoreConfig
(
spec
)
dsc
,
err
:=
fsrepo
.
AnyDatastoreConfig
(
spec
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -198,7 +203,7 @@ func TestMeasureConfig(t *testing.T) {
t
.
Fatal
(
err
)
}
dsc
,
err
:=
AnyDatastoreConfig
(
spec
)
dsc
,
err
:=
fsrepo
.
AnyDatastoreConfig
(
spec
)
if
err
!=
nil
{
t
.
Fatal
(
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