diff --git a/cmd/ipfswatch/main.go b/cmd/ipfswatch/main.go index 79ea24224d0..7fec4a0dc69 100644 --- a/cmd/ipfswatch/main.go +++ b/cmd/ipfswatch/main.go @@ -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 ( @@ -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) @@ -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