This repository was archived by the owner on Sep 11, 2020. It is now read-only.
storage/dotgit: search for incoming dir only once#935
Merged
mcuadros merged 2 commits intosrc-d:masterfrom Aug 29, 2018
Merged
Conversation
Search for incoming object directory was done once each time objects were accessed. This means a ReadDir of the objects path that is expensive. Now incoming directory is searched the first time an object is accessed and its name kept in DotGit to be reused. Signed-off-by: Javi Fontan <jfontan@gmail.com>
Contributor
Author
|
@noxora, can you check if this change is compatible with pre-commit hook? |
|
I do not see why this would not be compatible, it appears to be a solid change. |
ajnavarro
approved these changes
Aug 27, 2018
erizocosmico
approved these changes
Aug 27, 2018
Collaborator
|
I think new incoming directories can appear in subsequent calls? |
Contributor
Author
|
@smola, yes, that can happen if this is the use case.
While this is possible I don't think it's the common usage. Most probably go-git will be used inside the pre hook.
|
kuba--
reviewed
Aug 27, 2018
storage/filesystem/dotgit/dotgit.go
Outdated
| directoryContents, err := d.fs.ReadDir(objectsPath) | ||
| if err == nil { | ||
| for _, file := range directoryContents { | ||
| if strings.Split(file.Name(), "-")[0] == "incoming" && file.IsDir() { |
Contributor
There was a problem hiding this comment.
Is it the same as strings.HasPrefix(file.Name(), "incoming")
Also reformatted function comment and fixed some typos. Signed-off-by: Javi Fontan <jfontan@gmail.com>
|
@jfontan I thought similarly, it is possible that it could change, but if it is being used to write a hook, it shouldn't. However, if we were to treat this as volatile (which it could be, in some uncommon use cases) then this would be problematic. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Search for incoming object directory was done once each time objects were accessed. This means a ReadDir of the objects path that is expensive. Now incoming directory is searched the first time an object is accessed and its name kept in DotGit to be reused.
This has the drawback that if the incoming object directory is created after the repo is opened it won't be found.
Related to #887