MCPcopy
hub / github.com/dosco/graphjin / Stat

Method Stat

core/fstable/local.go:151–176  ·  view source on GitHub ↗
(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

149}
150
151func (l *Local) Stat(ctx context.Context, key string) (Entry, error) {
152 if err := ctx.Err(); err != nil {
153 return Entry{}, err
154 }
155 full, err := l.resolve(key)
156 if err != nil {
157 return Entry{}, err
158 }
159 info, err := os.Stat(full)
160 if err != nil {
161 if errors.Is(err, os.ErrNotExist) {
162 return Entry{}, ErrNotFound
163 }
164 return Entry{}, fmt.Errorf("fstable/local: stat %q: %w", key, err)
165 }
166 if info.IsDir() {
167 return Entry{}, ErrNotFound
168 }
169 return Entry{
170 Key: key,
171 Size: info.Size(),
172 ContentType: guessContentType(full),
173 ETag: fmt.Sprintf("%d-%d", info.Size(), info.ModTime().UnixNano()),
174 ModifiedAt: info.ModTime(),
175 }, nil
176}
177
178func (l *Local) Get(ctx context.Context, key string) (io.ReadCloser, Entry, error) {
179 entry, err := l.Stat(ctx, key)

Callers 2

GetMethod · 0.95

Calls 4

resolveMethod · 0.95
guessContentTypeFunction · 0.85
ErrMethod · 0.80
StatMethod · 0.65

Tested by 1