1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-09 09:35:03 +09:00

Migrate space hash

This commit is contained in:
mcrakhman 2025-01-20 18:36:38 +01:00
parent 5ceab3b7cd
commit 4f00849cab
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B

View file

@ -160,9 +160,20 @@ func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progr
if len(allErrors) > 0 {
return fmt.Errorf("migration failed: %w", errors.Join(allErrors...))
}
if err := s.migrateHash(ctx, oldStorage, newStorage); err != nil {
log.Warn("migration: failed to migrate hash", zap.Error(err))
}
return s.setMigrated(ctx, newStorage.AnyStore())
}
func (s *spaceMigrator) migrateHash(ctx context.Context, oldStorage oldstorage.SpaceStorage, newStorage spacestorage.SpaceStorage) error {
spaceHash, err := oldStorage.ReadSpaceHash()
if err != nil {
return err
}
return newStorage.StateStorage().SetHash(ctx, spaceHash)
}
func (s *spaceMigrator) checkMigrated(ctx context.Context, id string) (bool, spacestorage.SpaceStorage) {
storage, err := s.newProvider.WaitSpaceStorage(ctx, id)
if err != nil {