Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions cmd/ipfswatch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import (

fsnotify "github.com/fsnotify/fsnotify"
"github.com/ipfs/boxo/files"

"github.com/ipfs/kubo/plugin"
pluginbadgerds "github.com/ipfs/kubo/plugin/plugins/badgerds"
pluginflatfs "github.com/ipfs/kubo/plugin/plugins/flatfs"
pluginlevelds "github.com/ipfs/kubo/plugin/plugins/levelds"
pluginpebbleds "github.com/ipfs/kubo/plugin/plugins/pebbleds"
)

var (
Expand Down Expand Up @@ -60,6 +66,18 @@ func main() {
}
}

func loadDatastorePlugins(plugins []plugin.Plugin) error {
for _, pl := range plugins {
if pl, ok := pl.(plugin.PluginDatastore); ok {
err := fsrepo.AddDatastoreConfigHandler(pl.DatastoreTypeName(), pl.DatastoreConfigParser())
if err != nil {
return err
}
}
}
return nil
}

func run(ipfsPath, watchPath string) error {
log.Printf("running IPFSWatch on '%s' using repo at '%s'...", watchPath, ipfsPath)

Expand All @@ -77,6 +95,19 @@ func run(ipfsPath, watchPath string) error {
return err
}

if err = loadDatastorePlugins(pluginbadgerds.Plugins); err != nil {
return nil
}
if err = loadDatastorePlugins(pluginflatfs.Plugins); err != nil {
return nil
}
if err = loadDatastorePlugins(pluginlevelds.Plugins); err != nil {
return nil
}
if err = loadDatastorePlugins(pluginpebbleds.Plugins); err != nil {
return nil
}

r, err := fsrepo.Open(ipfsPath)
if err != nil {
// TODO handle case: daemon running
Expand Down
Loading