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

Method deduplicateEntries

pkg/workflow/action_cache.go:584–611  ·  view source on GitHub ↗

deduplicateEntries removes duplicate entries by keeping only the most precise version reference for each repo+SHA combination. For example, if both "actions/cache@v4" and "actions/cache@v4.3.0" point to the same SHA and version, only "actions/cache@v4.3.0" is kept.

()

Source from the content-addressed store, hash-verified

582// for each repo+SHA combination. For example, if both "actions/cache@v4" and "actions/cache@v4.3.0"
583// point to the same SHA and version, only "actions/cache@v4.3.0" is kept.
584func (c *ActionCache) deduplicateEntries() {
585 groups := c.groupEntriesByRepoAndSHA()
586 var toDelete []string
587 var deduplicationDetails []string
588 for ek, keys := range groups {
589 if len(keys) <= 1 {
590 continue
591 }
592 actionCacheLog.Printf("Found %d cache entries for %s with SHA %s", len(keys), ek.repo, truncateSHAForLog(ek.sha))
593 keyInfos := buildDedupKeyInfos(keys)
594 if len(keyInfos) <= 1 {
595 continue
596 }
597 keepVersion, removedKeys, removedVersions := collectDedupRemovals(keyInfos)
598 for _, removedKey := range removedKeys {
599 toDelete = append(toDelete, removedKey)
600 actionCacheLog.Printf("Deduplicating: keeping %s, removing %s", keyInfos[0].key, removedKey)
601 }
602 deduplicationDetails = append(deduplicationDetails, fmt.Sprintf("%s: kept %s, removed %s", ek.repo, keepVersion, strings.Join(removedVersions, ", ")))
603 }
604 c.deleteDedupEntries(toDelete)
605 if len(toDelete) > 0 {
606 actionCacheLog.Printf("Deduplicated %d entries, %d entries remaining", len(toDelete), len(c.Entries))
607 for _, detail := range deduplicationDetails {
608 actionCacheLog.Printf("Deduplication detail: %s", detail)
609 }
610 }
611}
612
613type deduplicationKey struct {
614 repo string

Callers 1

SaveMethod · 0.95

Calls 6

deleteDedupEntriesMethod · 0.95
truncateSHAForLogFunction · 0.85
buildDedupKeyInfosFunction · 0.85
collectDedupRemovalsFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected