Fix delete for disk indexes

This commit is contained in:
Benedikt Kulmann
2020-10-23 17:14:27 +02:00
parent 9a30688521
commit 55d1f78bda
5 changed files with 11 additions and 8 deletions
@@ -263,5 +263,5 @@ func (idx *Autoincrement) next() (int, error) {
// Delete deletes the index folder from its storage.
func (idx *Autoincrement) Delete() error {
return os.Remove(idx.indexRootDir)
return os.RemoveAll(idx.indexRootDir)
}
@@ -236,5 +236,5 @@ func (idx *NonUnique) FilesDir() string {
// Delete deletes the index folder from its storage.
func (idx *NonUnique) Delete() error {
return os.Remove(idx.indexRootDir)
return os.RemoveAll(idx.indexRootDir)
}
+1 -1
View File
@@ -223,5 +223,5 @@ func isValidSymlink(path string) (err error) {
// Delete deletes the index folder from its storage.
func (idx *Unique) Delete() error {
return os.Remove(idx.indexRootDir)
return os.RemoveAll(idx.indexRootDir)
}
+4 -1
View File
@@ -47,7 +47,10 @@ func (i Indexer) Reset() error {
for j := range i.indices {
for _, indices := range i.indices[j].IndicesByField {
for _, idx := range indices {
_ = idx.Delete()
err := idx.Delete()
if err != nil {
return err
}
}
}
delete(i.indices, j)
+4 -4
View File
@@ -75,8 +75,8 @@ func (r DiskRepo) LoadAccounts(ctx context.Context, a *[]*proto.Account) (err er
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{}
if err = r.LoadAccount(ctx, filepath.Base(path), acc); err != nil {
r.log.Err(err).Msg("could not load account")
if e := r.LoadAccount(ctx, filepath.Base(path), acc); e != nil {
r.log.Err(e).Msg("could not load account")
return nil
}
*a = append(*a, acc)
@@ -137,8 +137,8 @@ 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{}
if err = r.LoadGroup(ctx, filepath.Base(path), grp); err != nil {
r.log.Err(err).Msg("could not load group")
if e := r.LoadGroup(ctx, filepath.Base(path), grp); e != nil {
r.log.Err(e).Msg("could not load group")
return nil
}
*g = append(*g, grp)