1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-10 01:51:11 +09:00

Add check migrated method

This commit is contained in:
mcrakhman 2025-01-10 15:21:06 +01:00
parent 73e79a9173
commit faa7c53d63
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B

View file

@ -27,6 +27,7 @@ var ErrAlreadyMigrated = errors.New("already migrated")
type SpaceMigrator interface { type SpaceMigrator interface {
MigrateId(ctx context.Context, id string, progress Progress) (spacestorage.SpaceStorage, error) MigrateId(ctx context.Context, id string, progress Progress) (spacestorage.SpaceStorage, error)
CheckMigrated(ctx context.Context, id string) (bool, error)
} }
type Progress interface { type Progress interface {
@ -49,6 +50,14 @@ func NewSpaceMigrator(oldProvider oldstorage.SpaceStorageProvider, newProvider s
} }
} }
func (s *spaceMigrator) CheckMigrated(ctx context.Context, id string) (bool, error) {
migrated, storage := s.checkMigrated(ctx, id)
if storage != nil {
return migrated, storage.Close(ctx)
}
return false, nil
}
func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progress) (spacestorage.SpaceStorage, error) { func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progress) (spacestorage.SpaceStorage, error) {
migrated, storage := s.checkMigrated(ctx, id) migrated, storage := s.checkMigrated(ctx, id)
if migrated { if migrated {