MCPcopy
hub / github.com/air-verse/air / cacheFileChecksums

Method cacheFileChecksums

runner/engine.go:218–275  ·  view source on GitHub ↗

cacheFileChecksums calculates and stores checksums for each non-excluded file it finds from root.

(root string)

Source from the content-addressed store, hash-verified

216
217// cacheFileChecksums calculates and stores checksums for each non-excluded file it finds from root.
218func (e *Engine) cacheFileChecksums(root string) error {
219 return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
220 if err != nil {
221 if info == nil {
222 return err
223 }
224 if info.IsDir() {
225 return filepath.SkipDir
226 }
227 return err
228 }
229
230 if !info.Mode().IsRegular() {
231 if e.isTmpDir(path) || e.isTestDataDir(path) || isHiddenDirectory(path) || e.isExcludeDir(path) {
232 e.watcherDebug("!exclude checksum %s", e.config.rel(path))
233 return filepath.SkipDir
234 }
235
236 // Follow symbolic link
237 if e.config.Build.FollowSymlink && (info.Mode()&os.ModeSymlink) > 0 {
238 link, err := filepath.EvalSymlinks(path)
239 if err != nil {
240 return err
241 }
242 linkInfo, err := os.Stat(link)
243 if err != nil {
244 return err
245 }
246 if linkInfo.IsDir() {
247 err = e.watchPath(link)
248 if err != nil {
249 return err
250 }
251 }
252 return nil
253 }
254 }
255
256 if e.isExcludeFile(path) || !e.isIncludeExt(path) && !e.checkIncludeFile(path) {
257 e.watcherDebug("!exclude checksum %s", e.config.rel(path))
258 return nil
259 }
260
261 excludeRegex, err := e.isExcludeRegex(path)
262 if err != nil {
263 return err
264 }
265 if excludeRegex {
266 e.watcherDebug("!exclude checksum %s", e.config.rel(path))
267 return nil
268 }
269
270 // update the checksum cache for the current file
271 _ = e.isModified(path)
272
273 return nil
274 })
275}

Callers 1

watchPathMethod · 0.95

Calls 12

isTmpDirMethod · 0.95
isTestDataDirMethod · 0.95
isExcludeDirMethod · 0.95
watcherDebugMethod · 0.95
watchPathMethod · 0.95
isExcludeFileMethod · 0.95
isIncludeExtMethod · 0.95
checkIncludeFileMethod · 0.95
isExcludeRegexMethod · 0.95
isModifiedMethod · 0.95
isHiddenDirectoryFunction · 0.85
relMethod · 0.80

Tested by

no test coverage detected