Skip to content

Commit

Permalink
fix: return on error and chunk get
Browse files Browse the repository at this point in the history
  • Loading branch information
nugaon committed Jun 7, 2024
1 parent 9d99af1 commit df16c0c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/api/soc.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,23 @@ func (s *Service) socGetHandler(w http.ResponseWriter, r *http.Request) {

address, err := soc.CreateAddress(paths.ID, paths.Owner)
if err != nil {
logger.Error(err, "soc address cannot be created")
jsonhttp.BadRequest(w, "soc address cannot be created")
return
}

sch, err := s.storer.ChunkStore().Get(r.Context(), address)
getter := s.storer.Download(true)
sch, err := getter.Get(r.Context(), address)
if err != nil {
jsonhttp.NotFound(w, "requested chunk cannot be retrievable")
logger.Error(err, "soc retrieval has been failed")
jsonhttp.NotFound(w, "requested chunk cannot be retrieved")
return
}
socCh, err := soc.FromChunk(sch)
if err != nil {
logger.Error(err, "chunk is not a signle owner chunk")
jsonhttp.InternalServerError(w, "chunk is not a single owner chunk")
return
}

sig := socCh.Signature()
Expand Down

0 comments on commit df16c0c

Please sign in to comment.