Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a feature to check the .git/lfs/objects directory for local file objects before downloading remote parts, improving efficiency in retrieving LFS data.
- In page.go, a new field "po" along with a conditional branch in Fetch checks for local LFS objects.
- In node_test.go, minor test comment refinements and reordering of git push operations help streamline the test flow.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| page.go | Adds a local lookup for LFS objects by introducing a new field and logic in Fetch. |
| node_test.go | Updates comments and adjusts the placement of git push commands to refine testing. |
Comments suppressed due to low confidence (1)
page.go:41
- [nitpick] The variable name 'po' is ambiguous. Consider renaming it to a more descriptive name like 'lfsObjectsPath' to improve code readability.
po string // .git/lfs/objects
Comment on lines
+165
to
+172
| if f, _ := os.Open(path); f != nil { | ||
| defer f.Close() | ||
| if _, err := f.Seek(off, io.SeekStart); err == nil { | ||
| _, err = io.CopyN(w, f, end-off) | ||
| log.Printf("local: oid=(%s) %dMB %d/%d err=%v", ptr.Oid, pagesize/(1024*1024), pageNum+1, (size+pagesize-1)/pagesize, err) | ||
| return err | ||
| } | ||
| } |
There was a problem hiding this comment.
Consider checking and handling the error returned from os.Open instead of ignoring it; this will help diagnose issues reliably during local file access.
Suggested change
| if f, _ := os.Open(path); f != nil { | |
| defer f.Close() | |
| if _, err := f.Seek(off, io.SeekStart); err == nil { | |
| _, err = io.CopyN(w, f, end-off) | |
| log.Printf("local: oid=(%s) %dMB %d/%d err=%v", ptr.Oid, pagesize/(1024*1024), pageNum+1, (size+pagesize-1)/pagesize, err) | |
| return err | |
| } | |
| } | |
| f, err := os.Open(path) | |
| if err != nil { | |
| log.Printf("failed to open file: %s, error: %v", path, err) | |
| return err | |
| } | |
| defer f.Close() | |
| if _, err := f.Seek(off, io.SeekStart); err == nil { | |
| _, err = io.CopyN(w, f, end-off) | |
| log.Printf("local: oid=(%s) %dMB %d/%d err=%v", ptr.Oid, pagesize/(1024*1024), pageNum+1, (size+pagesize-1)/pagesize, err) | |
| return err | |
| } |
Signed-off-by: Rueian <rueiancsie@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Local git-lfs files added by the
git addwill be copied to.git/lfs/objects. We should treat it as a remote as well.