Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Refactor

Neeraj Gupta3a278a54467b
diff --git a/main.go b/main.go
index 27d9428ed8..2e72e97f06 100644
--- a/main.go
+++ b/main.go
@@ -4,9 +4,6 @@ import (
"cli-go/cmd"
"cli-go/internal/api"
"cli-go/pkg"
- "fmt"
-
- bolt "go.etcd.io/bbolt"
)
func main() {
@@ -14,20 +11,16 @@ func main() {
if err != nil {
panic(err)
}
- db.Update(func(tx *bolt.Tx) error {
- _, err := tx.CreateBucketIfNotExists([]byte(pkg.AccBucket))
- if err != nil {
- return fmt.Errorf("create bucket: %s", err)
- }
- return nil
- })
- var client = api.NewClient(api.Params{
- Debug: false,
- Host: "http://localhost:8080",
- })
ctrl := pkg.ClICtrl{
- Client: client,
- DB: db,
+ Client: api.NewClient(api.Params{
+ Debug: false,
+ Host: "http://localhost:8080",
+ }),
+ DB: db,
+ }
+ err = ctrl.Init()
+ if err != nil {
+ panic(err)
}
defer func() {
if err := db.Close(); err != nil {
diff --git a/pkg/controller.go b/pkg/controller.go
index c1eb5eb979..d60e1f0dc7 100644
--- a/pkg/controller.go
+++ b/pkg/controller.go
@@ -2,6 +2,7 @@ package pkg
import (
"cli-go/internal/api"
+ "fmt"
bolt "go.etcd.io/bbolt"
)
@@ -9,3 +10,13 @@ type ClICtrl struct {
Client *api.Client
DB *bolt.DB
}
+
+func (c *ClICtrl) Init() error {
+ return c.DB.Update(func(tx *bolt.Tx) error {
+ _, err := tx.CreateBucketIfNotExists([]byte(AccBucket))
+ if err != nil {
+ return fmt.Errorf("create bucket: %s", err)
+ }
+ return nil
+ })
+}