(ctx context.Context, commit ksuid.KSUID)
| 63 | } |
| 64 | |
| 65 | func (s *Store) Get(ctx context.Context, commit ksuid.KSUID) (*Object, error) { |
| 66 | if o, ok := s.cache.Get(commit); ok { |
| 67 | return o, nil |
| 68 | } |
| 69 | r, err := s.engine.Get(ctx, s.pathOf(commit)) |
| 70 | if err != nil { |
| 71 | return nil, err |
| 72 | } |
| 73 | o, err := DecodeObject(r) |
| 74 | if err == ErrBadCommitObject { |
| 75 | err = fmt.Errorf("system error: %s: %w", s.pathOf(commit), ErrBadCommitObject) |
| 76 | } |
| 77 | if closeErr := r.Close(); err == nil { |
| 78 | err = closeErr |
| 79 | } |
| 80 | if err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | s.cache.Add(commit, o) |
| 84 | return o, nil |
| 85 | } |
| 86 | |
| 87 | func (s *Store) pathOf(commit ksuid.KSUID) *storage.URI { |
| 88 | return s.path.JoinPath(commit.String() + ".bsup") |
no test coverage detected