MCPcopy Create free account
hub / github.com/github/gh-aw / Get

Method Get

pkg/parser/import_cache.go:72–92  ·  view source on GitHub ↗

Get retrieves a cached file path if it exists sha parameter should be the resolved commit SHA

(owner, repo, path, sha string)

Source from the content-addressed store, hash-verified

70// Get retrieves a cached file path if it exists
71// sha parameter should be the resolved commit SHA
72func (c *ImportCache) Get(owner, repo, path, sha string) (string, bool) {
73 // Use SHA-based approach: cache files are stored by commit SHA
74 // Cache path: .github/aw/imports/owner/repo/sha/sanitized_path.md
75 sanitizedPath := sanitizePath(path)
76 relativeCachePath := filepath.Join(ImportCacheDir, owner, repo, sha, sanitizedPath)
77 fullCachePath := filepath.Join(c.baseDir, relativeCachePath)
78
79 // Check if the cached file exists
80 if _, err := os.Stat(fullCachePath); err != nil {
81 if os.IsNotExist(err) {
82 importCacheLog.Printf("Cache miss: %s/%s/%s@%s", owner, repo, path, sha)
83 } else {
84 // Log other types of errors (permissions, I/O issues, etc.)
85 importCacheLog.Printf("Cache access error for %s/%s/%s@%s: %v", owner, repo, path, sha, err)
86 }
87 return "", false
88 }
89
90 importCacheLog.Printf("Cache hit: %s/%s/%s@%s -> %s", owner, repo, path, sha, fullCachePath)
91 return fullCachePath, true
92}
93
94// Set stores a new cache entry by saving the content to the cache directory
95// sha parameter should be the resolved commit SHA

Callers 15

TestImportCacheFunction · 0.95
computeMaxFieldLenFunction · 0.45
collectTableFieldsFunction · 0.45
checkRemoteSymlinkFunction · 0.45
fetchRemoteFileContentFunction · 0.45

Calls 2

sanitizePathFunction · 0.85
PrintfMethod · 0.45