Skip to content

Commit

Permalink
be forgiving
Browse files Browse the repository at this point in the history
  • Loading branch information
kalbasit committed Dec 6, 2024
1 parent 2c8337a commit a8ca9ea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ func (c *Cache) getNarFromStore(hash, compression string) (int64, io.ReadCloser,
nr, err := c.db.GetNarRecord(tx, hash)
if err != nil {
// TODO: If record not found, record it instead!
if errors.Is(err, database.ErrNotFound) {
return size, r, nil
}

return 0, nil, fmt.Errorf("error fetching the nar record: %w", err)
}

Expand Down Expand Up @@ -438,6 +442,10 @@ func (c *Cache) getNarInfoFromStore(hash string) (*narinfo.NarInfo, error) {
nir, err := c.db.GetNarInfoRecord(tx, hash)
if err != nil {
// TODO: If record not found, record it instead!
if errors.Is(err, database.ErrNotFound) {
return ni, nil
}

return nil, fmt.Errorf("error fetching the narinfo record: %w", err)
}

Expand Down

0 comments on commit a8ca9ea

Please sign in to comment.