MCPcopy
hub / github.com/wavetermdev/waveterm / loadFileForRead

Method loadFileForRead

pkg/filestore/blockstore_cache.go:114–126  ·  view source on GitHub ↗

does not populate the cache entry, returns err if file does not exist

(ctx context.Context)

Source from the content-addressed store, hash-verified

112
113// does not populate the cache entry, returns err if file does not exist
114func (entry *CacheEntry) loadFileForRead(ctx context.Context) (*WaveFile, error) {
115 if entry.File != nil {
116 return entry.File, nil
117 }
118 file, err := dbGetZoneFile(ctx, entry.ZoneId, entry.Name)
119 if err != nil {
120 return nil, fmt.Errorf("error getting file: %w", err)
121 }
122 if file == nil {
123 return nil, fs.ErrNotExist
124 }
125 return file, nil
126}
127
128func withLock(s *FileStore, zoneId string, name string, fn func(*CacheEntry) error) error {
129 entry := s.getEntryAndPin(zoneId, name)

Callers 3

loadFileIntoCacheMethod · 0.95
readAtMethod · 0.95
StatMethod · 0.80

Calls 1

dbGetZoneFileFunction · 0.85

Tested by

no test coverage detected