Skip to content

Avoid re-uploading existing Go cache entries#513

Open
jacobwgillespie wants to merge 2 commits into
mainfrom
gocacheprog-duplicates
Open

Avoid re-uploading existing Go cache entries#513
jacobwgillespie wants to merge 2 commits into
mainfrom
gocacheprog-duplicates

Conversation

@jacobwgillespie
Copy link
Copy Markdown
Member

@jacobwgillespie jacobwgillespie commented May 26, 2026

Note

Medium Risk
Changes when cache entries are uploaded remotely; incorrect wrote detection could skip needed uploads, though behavior is covered by new tests.

Overview
Disk cache puts now return whether bytes were actually written. When the object and action index already exist at the expected size, the local put is a no-op and reports no write.

Remote uploads are skipped on those no-op puts (and when outputID is empty), so repeat Put calls for the same entry no longer spawn background HTTP PUTs to Depot. Parent directories are created with MkdirAll before writing cache files.

Handler metrics for get/put were adjusted so deferred error/hit/miss accounting still runs via an explicit retErr instead of named return parameters. Tests cover “second put does not hit remote” and the disk wrote flag.

Reviewed by Cursor Bugbot for commit f51083f. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Named return wrote shadowed by different-typed local variable
    • Renamed the local byte count from writeAtomic to bytesWritten so it no longer shadows the named boolean return value.

Create PR

Or push these changes by commenting:

@cursor push 6b4e26b361
Preview (6b4e26b361)
diff --git a/pkg/cmd/gocache/gocache.go b/pkg/cmd/gocache/gocache.go
--- a/pkg/cmd/gocache/gocache.go
+++ b/pkg/cmd/gocache/gocache.go
@@ -613,12 +613,12 @@
 		}
 		zf.Close()
 	} else {
-		wrote, err := writeAtomic(file, body)
+		bytesWritten, err := writeAtomic(file, body)
 		if err != nil {
 			return "", false, fmt.Errorf("unable to write to disk: %w", err)
 		}
-		if wrote != size {
-			return "", false, fmt.Errorf("wrote %d bytes, expected %d", wrote, size)
+		if bytesWritten != size {
+			return "", false, fmt.Errorf("wrote %d bytes, expected %d", bytesWritten, size)
 		}
 	}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit dd3a563. Configure here.

Comment thread pkg/cmd/gocache/gocache.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant