Skip to content

Commit

Permalink
Merge pull request #1163 from anyproto/go-3296-shared-space-broken-image
Browse files Browse the repository at this point in the history


GO-3296: Gateway: retry serving images
  • Loading branch information
deff7 authored Apr 22, 2024
2 parents e5dfad7 + b8cf4d9 commit 33df40b
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 252 deletions.
2 changes: 2 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ packages:
github.com/anyproto/anytype-heart/core/files:
interfaces:
Service:
File:
Image:
github.com/anyproto/anytype-heart/core/files/fileacl:
interfaces:
Service:
Expand Down
2 changes: 0 additions & 2 deletions core/domain/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ package domain

import "errors"

var ErrFileNotFound = errors.New("file not found")

var ErrValidationFailed = errors.New("validation failed")
6 changes: 0 additions & 6 deletions core/files/fileobject/fileindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fileobject

import (
"context"
"errors"
"fmt"
"strings"
"sync"
Expand Down Expand Up @@ -207,11 +206,6 @@ func (ind *indexer) indexFile(ctx context.Context, id domain.FullID, fileId doma

func (ind *indexer) injectMetadataToState(ctx context.Context, st *state.State, fileId domain.FullFileId, id domain.FullID) error {
details, typeKey, err := ind.buildDetails(ctx, fileId)
if errors.Is(err, domain.ErrFileNotFound) {
log.With("fileId", fileId.FileId, "objectId", id.ObjectID).Errorf("build details: %v", err)
ind.markFileAsNotFound(st)
return nil
}
if err != nil {
return fmt.Errorf("build details: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion core/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ func (s *service) FileByHash(ctx context.Context, id domain.FullFileId) (File, e
fileList, err = s.fileIndexInfo(ctx, id, false)
if err != nil {
log.With("fileId", id.FileId.String()).Errorf("FileByHash: failed to retrieve from IPFS: %s", err)
return nil, domain.ErrFileNotFound
return nil, err
}
ok, err := s.fileStore.IsFileImported(id.FileId)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions core/files/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ func (s *service) ImageByHash(ctx context.Context, id domain.FullFileId) (Image,
// index image files info from ipfs
files, err = s.fileIndexInfo(ctx, id, true)
if err != nil {
log.Errorf("ImageByHash: failed to retrieve from IPFS: %s", err)
return nil, domain.ErrFileNotFound
return nil, err
}
}

Expand Down
176 changes: 28 additions & 148 deletions core/files/mock_files/mock_Image.go

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

1 change: 0 additions & 1 deletion core/filestorage/filesync/filesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type FileSync interface {
UpdateNodeUsage(ctx context.Context) error
NodeUsage(ctx context.Context) (usage NodeUsage, err error)
SpaceStat(ctx context.Context, spaceId string) (ss SpaceStat, err error)
FileStat(ctx context.Context, spaceId string, fileId domain.FileId) (fs FileStat, err error)
FileListStats(ctx context.Context, spaceId string, hashes []domain.FileId) ([]FileStat, error)
DebugQueue(*http.Request) (*QueueInfo, error)
SendImportEvents()
Expand Down
58 changes: 0 additions & 58 deletions core/filestorage/filesync/mock_filesync/mock_FileSync.go

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

Loading

0 comments on commit 33df40b

Please sign in to comment.