Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: preload fuze and full files tree #239

Merged
merged 2 commits into from
Mar 21, 2021
Merged

Conversation

conwnet
Copy link
Owner

@conwnet conwnet commented Mar 20, 2021

Now, if the user open a repository in GitHub1s, it will only fetch the first level files. (In order to display the content faster)
And when the user press Ctrl/Command + P, it will use the recursive=true param of get-a-tree API to fetch all files, then populate the files into the fileSystemProvider's cache:

insertGitHubRESTEntryToDirectory(githubEntry, rootDirectory);

So if we haven't ever press the Ctrl/Commond + P, we need make a get-a-tree request every time you open a new folder, which is slow and waste.

I think we can fetch the full files tree sliently after the page loaded. Although it may waste a request, but it's will not to create a new request when the user opens another folder.

Related API: https://docs.github.com/en/rest/reference/git#get-a-tree

@vercel
Copy link

vercel bot commented Mar 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vscode-github1s/github1s/9ajQ4cw2rMzv1sVAVPjVmhiiDx3C
✅ Preview: https://github1s-git-feature-preload-tree-vscode-github1s.vercel.app

Copy link
Collaborator

@xcv58 xcv58 left a comment

Choose a reason for hiding this comment

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

I'm not sure whether it's this PR that causes the issue:

The app is calling the API twice: https://api.github.com/repos/conwnet/github1s/git/trees/HEAD:

And if we could call it with recursive=1, in theory. There should not be any extra call to get the directory.

I understand sometime the call with recursive=1 might be slow, calling the API to get first-level directories/files would speed up the file tree view. I suggest we try to remove the addition API call like https://api.github.com/repos/conwnet/github1s/git/trees/HEAD:

image

reproduce link: https://github1s-git-feature-preload-tree-vscode-github1s.vercel.app/conwnet/github1s

Please feel free to merge this PR if you think we should deal with the race network call in another PR.

@xcv58
Copy link
Collaborator

xcv58 commented Mar 21, 2021

Confirmed the double API calls is not related to this PR, it happens on latest master https://github1s-jkn7hfhgo-vscode-github1s.vercel.app/

@conwnet
Copy link
Owner Author

conwnet commented Mar 21, 2021

Confirmed the double API calls is not related to this PR, it happens on latest master https://github1s-jkn7hfhgo-vscode-github1s.vercel.app/

Thank you so much for your infomation. The double api calls on request without the param recursive=1 is seems a bug. I will try to find it on that next.❤️

Another reason I don't use the recursive=1 for the readDirectory is: It has a higher probability of being truncated, for example:
https://api.github.com/repos/chromium/chromium/git/trees/HEAD:?recursive=1

the response:

{
    sha: '...',
    url: '...',
    tree: [...],
    truncated: true // truncated
}

@conwnet conwnet merged commit 9c0f0d1 into master Mar 21, 2021
@conwnet conwnet deleted the feature/preload-tree branch March 21, 2021 07:36
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.

None yet

3 participants