Skip to content

Commit

Permalink
Fallback to trying old layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-Wilson committed Jul 22, 2024
1 parent 2dbd81c commit 4fdae71
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions das/local_file_storage_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,21 @@ func (s *LocalFileStorageService) Close(ctx context.Context) error {

func (s *LocalFileStorageService) GetByHash(ctx context.Context, key common.Hash) ([]byte, error) {
log.Trace("das.LocalFileStorageService.GetByHash", "key", pretty.PrettyHash(key), "this", s)
var batchPath string
if s.enableLegacyLayout {
batchPath = s.legacyLayout.batchPath(key)
} else {
batchPath = s.layout.batchPath(key)
}

legacyBatchPath := s.legacyLayout.batchPath(key)
batchPath := s.layout.batchPath(key)

data, err := os.ReadFile(batchPath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, ErrNotFound
data, err = os.ReadFile(legacyBatchPath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil, ErrNotFound
}
return nil, err
}
return data, nil
}
return nil, err
}
Expand Down

0 comments on commit 4fdae71

Please sign in to comment.