mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 09:35:03 +09:00
Tree migrator fixes
This commit is contained in:
parent
488823d55c
commit
74b0001955
3 changed files with 13 additions and 3 deletions
|
@ -52,12 +52,12 @@ func (mp *migratePool) Run() {
|
|||
func (mp *migratePool) sendLoop() {
|
||||
for {
|
||||
f, err := mp.batch.WaitOne(context.Background())
|
||||
mp.wg.Done()
|
||||
if err != nil {
|
||||
log.Debug("close send loop", zap.Error(err))
|
||||
return
|
||||
}
|
||||
f()
|
||||
mp.wg.Done()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage/oldstorage"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
|
@ -88,7 +90,7 @@ func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progr
|
|||
}()
|
||||
treeStorage, err := oldStorage.TreeStorage(id)
|
||||
if err != nil {
|
||||
allErrors = append(allErrors, fmt.Errorf("migration: failed to get tree storage: %w", err))
|
||||
log.Warn("migration: failed to get old tree storage", zap.String("id", id), zap.Error(err))
|
||||
return
|
||||
}
|
||||
err = tm.migrateTreeStorage(ctx, treeStorage, newStorage.HeadStorage(), newStorage.AnyStore())
|
||||
|
|
|
@ -2,6 +2,7 @@ package migration
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
anystore "github.com/anyproto/any-store"
|
||||
|
@ -10,6 +11,7 @@ import (
|
|||
"github.com/anyproto/any-sync/commonspace/object/acl/list"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
|
||||
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
|
||||
"github.com/anyproto/any-sync/commonspace/spacestorage/oldstorage"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anyproto/any-sync/util/slice"
|
||||
|
@ -48,9 +50,15 @@ func (tm *treeMigrator) migrateTreeStorage(ctx context.Context, storage oldstora
|
|||
}
|
||||
tm.dfs(ctx, heads, rootChange.Id)
|
||||
newStorage, err := objecttree.CreateStorage(ctx, rootChange, headStorage, store)
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, treestorage.ErrTreeExists) {
|
||||
return fmt.Errorf("migration: failed to create new storage: %w", err)
|
||||
}
|
||||
if errors.Is(err, treestorage.ErrTreeExists) {
|
||||
newStorage, err = objecttree.NewStorage(ctx, rootChange.Id, headStorage, store)
|
||||
if err != nil {
|
||||
return fmt.Errorf("migration: failed to start old storage: %w", err)
|
||||
}
|
||||
}
|
||||
objTree, err := objecttree.BuildObjectTree(newStorage, tm.aclList)
|
||||
if err != nil {
|
||||
return fmt.Errorf("migration: failed to build object tree: %w", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue