MCPcopy
hub / github.com/daptin/daptin / isFileModified

Function isFileModified

server/subsite_cache.go:250–268  ·  view source on GitHub ↗

isFileModified checks if the file on disk has been modified compared to cache

(filePath string, cacheEntry *SubsiteCacheEntry)

Source from the content-addressed store, hash-verified

248
249// isFileModified checks if the file on disk has been modified compared to cache
250func isFileModified(filePath string, cacheEntry *SubsiteCacheEntry) bool {
251 fileInfo, err := os.Stat(filePath)
252 if err != nil {
253 // If we can't stat the file, consider it modified
254 return true
255 }
256
257 // Check modification time
258 if fileInfo.ModTime().After(cacheEntry.LastModified) {
259 return true
260 }
261
262 // For extra verification, we could also check file size
263 if fileInfo.Size() != int64(len(cacheEntry.Content)) {
264 return true
265 }
266
267 return false
268}
269
270// isCacheExpired checks if a cache entry is expired
271func isCacheExpired(entry *SubsiteCacheEntry) bool {

Callers 2

isCacheExpiredFunction · 0.85
getFromCacheFunction · 0.85

Calls 3

StatMethod · 0.80
ModTimeMethod · 0.80
SizeMethod · 0.80

Tested by

no test coverage detected