Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions debug/spacechecker/spacechecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"

anystore "github.com/anyproto/any-store"
"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/app/logger"
"github.com/anyproto/any-sync/commonspace/spacestorage"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (s *spaceChecker) Check(ctx context.Context, spaceId string) (res Result, e

// 1. Get local status from index storage
localStatusStr, localErr := s.getLocalStatus(ctx, spaceId, &res)
if localErr != nil {
if localErr != nil && !errors.Is(localErr, anystore.ErrDocNotFound) {
return res, fmt.Errorf("get local status: %w", localErr)
}

Expand Down Expand Up @@ -108,6 +109,7 @@ func (s *spaceChecker) Fix(ctx context.Context, spaceId string) (Result, error)

switch {
// coordStatus: removed, localStatus: not removed or storageExists: true - remove space and switch local status
// also handles case when local entry doesn't exist (localStatus: unknown)
case coordStatus == "removed" && (localStatus != "removed" || storageExists):
if storageExists {
err = s.storageService.DeleteSpaceStorage(ctx, spaceId)
Expand Down Expand Up @@ -162,14 +164,14 @@ func (s *spaceChecker) Fix(ctx context.Context, spaceId string) (Result, error)
}

func (s *spaceChecker) getLocalStatus(ctx context.Context, spaceId string, res *Result) (statusStr string, err error) {
status, err := s.storageService.IndexStorage().SpaceStatus(ctx, spaceId)
entry, err := s.storageService.IndexStorage().SpaceStatusEntry(ctx, spaceId)
if err != nil {
res.LocalStatus = "unknown"
res.LocalStatusError = err.Error()
res.Log = append(res.Log, fmt.Sprintf("localStatus: error getting status: %s", err))
return "unknown", err
}
statusStr = localStatusString(status)
statusStr = localStatusString(entry.Status)
res.LocalStatus = statusStr
res.Log = append(res.Log, fmt.Sprintf("localStatus: %s", statusStr))
return statusStr, nil
Expand Down
1 change: 1 addition & 0 deletions nodestorage/indexstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type IndexStorage interface {
UpdateHashes(ctx context.Context, updateFunc func(spaceId, newHash, oldHash string) (newNewHash, newOldHash string, shouldUpdate bool)) (err error)
SetSpaceStatus(ctx context.Context, spaceId string, status SpaceStatus, recId string) (err error)
SpaceStatus(ctx context.Context, spaceId string) (status SpaceStatus, err error)
SpaceStatusEntry(ctx context.Context, spaceId string) (entry SpaceStatusEntry, err error)
MarkArchived(ctx context.Context, spaceId string, compressedSize, uncompressedSize int64) (err error)
MarkError(ctx context.Context, spaceId string, errString string) (err error)
DeletionLogId(ctx context.Context) (id string, err error)
Expand Down
15 changes: 15 additions & 0 deletions nodestorage/mock_nodestorage/mock_nodestorage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.