mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-12 22:39:34 -05:00
Reformat responses
This commit is contained in:
@@ -20,12 +20,12 @@ func DeleteIndex(cdf *config.Config) *cli.Command {
|
||||
idxSvcID := "com.owncloud.api.accounts"
|
||||
idxSvc := index.NewIndexService(idxSvcID, grpc.NewClient())
|
||||
|
||||
rsp, err := idxSvc.RebuildIndex(context.Background(), &index.RebuildIndexRequest{})
|
||||
_, err := idxSvc.RebuildIndex(context.Background(), &index.RebuildIndexRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("deleted: %+v", rsp.Indices)
|
||||
fmt.Print("index rebuilt successfully")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -70,27 +70,23 @@ func recreateContainers(idx *indexer.Indexer, cfg *config.Config) error {
|
||||
|
||||
// reindexDocuments loads all existing documents and adds them to the index.
|
||||
func reindexDocuments(ctx context.Context, repo storage.Repo, index *indexer.Indexer) error {
|
||||
accounts := &storage.Accounts{
|
||||
Accounts: make([]*proto.Account, 0),
|
||||
}
|
||||
if err := repo.LoadAccounts(ctx, accounts); err != nil {
|
||||
accounts := make([]*proto.Account, 0)
|
||||
if err := repo.LoadAccounts(ctx, &accounts); err != nil {
|
||||
return err
|
||||
}
|
||||
for i := range accounts.Accounts {
|
||||
_, err := index.Add(accounts.Accounts[i])
|
||||
for i := range accounts {
|
||||
_, err := index.Add(accounts[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
groups := &storage.Groups{
|
||||
Groups: make([]*proto.Group, 0),
|
||||
}
|
||||
if err := repo.LoadGroups(ctx, groups); err != nil {
|
||||
groups := make([]*proto.Group, 0)
|
||||
if err := repo.LoadGroups(ctx, &groups); err != nil {
|
||||
return err
|
||||
}
|
||||
for i := range groups.Groups {
|
||||
_, err := index.Add(groups.Groups[i])
|
||||
for i := range groups {
|
||||
_, err := index.Add(groups[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func (r CS3Repo) LoadAccount(ctx context.Context, id string, a *proto.Account) (
|
||||
}
|
||||
|
||||
// LoadAccounts loads all the accounts from the cs3 api
|
||||
func (r CS3Repo) LoadAccounts(ctx context.Context, a *Accounts) (err error) {
|
||||
func (r CS3Repo) LoadAccounts(ctx context.Context, a *[]*proto.Account) (err error) {
|
||||
t, err := r.authenticate(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -120,7 +120,7 @@ func (r CS3Repo) LoadAccounts(ctx context.Context, a *Accounts) (err error) {
|
||||
log.Err(err).Msg("could not load account")
|
||||
continue
|
||||
}
|
||||
a.Accounts = append(a.Accounts, acc)
|
||||
*a = append(*a, acc)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func (r CS3Repo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err
|
||||
}
|
||||
|
||||
// LoadGroups loads all the groups from the cs3 api
|
||||
func (r CS3Repo) LoadGroups(ctx context.Context, g *Groups) (err error) {
|
||||
func (r CS3Repo) LoadGroups(ctx context.Context, g *[]*proto.Group) (err error) {
|
||||
t, err := r.authenticate(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -234,7 +234,7 @@ func (r CS3Repo) LoadGroups(ctx context.Context, g *Groups) (err error) {
|
||||
log.Err(err).Msg("could not load account")
|
||||
continue
|
||||
}
|
||||
g.Groups = append(g.Groups, grp)
|
||||
*g = append(*g, grp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func (r DiskRepo) LoadAccount(ctx context.Context, id string, a *proto.Account)
|
||||
}
|
||||
|
||||
// LoadAccounts loads all the accounts from the local filesystem
|
||||
func (r DiskRepo) LoadAccounts(ctx context.Context, a *Accounts) (err error) {
|
||||
func (r DiskRepo) LoadAccounts(ctx context.Context, a *[]*proto.Account) (err error) {
|
||||
root := filepath.Join(r.cfg.Repo.Disk.Path, accountsFolder)
|
||||
return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||
acc := &proto.Account{}
|
||||
@@ -79,7 +79,7 @@ func (r DiskRepo) LoadAccounts(ctx context.Context, a *Accounts) (err error) {
|
||||
r.log.Err(err).Msg("could not load account")
|
||||
return nil
|
||||
}
|
||||
a.Accounts = append(a.Accounts, acc)
|
||||
*a = append(*a, acc)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func (r DiskRepo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err
|
||||
}
|
||||
|
||||
// LoadGroups loads all the groups from the local filesystem
|
||||
func (r DiskRepo) LoadGroups(ctx context.Context, g *Groups) (err error) {
|
||||
func (r DiskRepo) LoadGroups(ctx context.Context, g *[]*proto.Group) (err error) {
|
||||
root := filepath.Join(r.cfg.Repo.Disk.Path, groupsFolder)
|
||||
return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
|
||||
grp := &proto.Group{}
|
||||
@@ -141,7 +141,7 @@ func (r DiskRepo) LoadGroups(ctx context.Context, g *Groups) (err error) {
|
||||
r.log.Err(err).Msg("could not load group")
|
||||
return nil
|
||||
}
|
||||
g.Groups = append(g.Groups, grp)
|
||||
*g = append(*g, grp)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,22 +11,14 @@ const (
|
||||
groupsFolder = "groups"
|
||||
)
|
||||
|
||||
type Accounts struct {
|
||||
Accounts []*proto.Account
|
||||
}
|
||||
|
||||
type Groups struct {
|
||||
Groups []*proto.Group
|
||||
}
|
||||
|
||||
// Repo defines the storage operations
|
||||
type Repo interface {
|
||||
WriteAccount(ctx context.Context, a *proto.Account) (err error)
|
||||
LoadAccount(ctx context.Context, id string, a *proto.Account) (err error)
|
||||
LoadAccounts(ctx context.Context, a *Accounts) (err error)
|
||||
LoadAccounts(ctx context.Context, a *[]*proto.Account) (err error)
|
||||
DeleteAccount(ctx context.Context, id string) (err error)
|
||||
WriteGroup(ctx context.Context, g *proto.Group) (err error)
|
||||
LoadGroup(ctx context.Context, id string, g *proto.Group) (err error)
|
||||
LoadGroups(ctx context.Context, g *Groups) (err error)
|
||||
LoadGroups(ctx context.Context, g *[]*proto.Group) (err error)
|
||||
DeleteGroup(ctx context.Context, id string) (err error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user