Skip to content

Reload HTTP fetch cache when cloning - #12308

Merged
tidy-dev merged 1 commit into
developmentfrom
reload-that-cache
May 28, 2021
Merged

tidy-dev merged 1 commit into
developmentfrom
reload-that-cache

Conversation

@tidy-dev

@tidy-dev tidy-dev commented May 27, 2021 •

Copy link
Copy Markdown
Contributor

Closes #3855

Description

During cloning , we make an http request ending in repos/${owner}/${name} (which is just getting the details of the repo).

For example, If I clone my repo called awesome-repo. It would be baseurl/repos/tidy-dev/awesome-repo.

By default, on this request:

default — The browser looks for a matching request in its HTTP cache.
If there is a match and it is fresh, it will be returned from the cache.
If there is a match but it is stale, the browser will make a conditional request to the remote server. If the server indicates that the resource has not changed, it will be returned from the cache. Otherwise the resource will be downloaded from the server and the cache will be updated.
If there is no match, the browser will make a normal request, and will update the cache with the downloaded resource.

The reason this probably stays "fresh" is because we use that same call many other places like when fetching.

Thus, if I have an already cloned repo of awesome-repo that means I have a cache for it. If I change it's name to not-so-awesome-repo and recreate a new repo called awesome-repo. When desktop tries to clone it and hits that same baseurl/repos/tidy-dev/awesome-repo, it gets the details or ID for the old awesome-repo which is now the not-so-awesome-repo.

Solution: Whenever we clone, we do not check the cache. This is intuitive anyways because cloning usually is our first contact with a repo and we wouldn't generally have a cache for it.

Notes on previous PRs that we thought might have fixed this.
There are two portions to this issue:

  1. If I rename a repository awesome-repo to not-so-awesome-repo on github.com, I want that rename reflected in Desktop. This is what Update the remote url if it changed. #8132 does - during a repository refresh cycle it detects the a change in the cloneURL when it is renamed and correctly updates the name of repository locally.

  2. More of a bug, if after I do step 1, I make a new repo called awesome-repo (the old name) and clone it. I want it to be named and update awesome-repo but it was named and updating to not-so-awesome-repo. This may not have updated the name to 'not-so-awesome-repo when this issue was originally entered as I would expect the updated name only happens because of Update the remote url if it changed. #8132, however bug of it pointing to not-so-awesome-repo may have still existed because the cache that made it so the id we retrieved for 'awesome-repo' was still now the id of not-so-awesome-repo.

There is reference to this being closed by #9138 in this comment. Looking at the code.. I am not sure how this one did impact this.. but maybe there is more I don't understand. Only thing I suspect is that because step 1 changed the nature/timing/repro steps of this bug that it may have appeared to be gone.

Other thing to be aware of that I don't think we can mitigate without some kind of .com webhook to make the rename detection more immediate is if a user does 1 and 2 in quick succession not allowing desktop to detect the rename of the original repo. The cache will now be updated with 2's details and so the first instance of the repo in Desktop will now effectively be a duplicate of the new one in step two with the old name. If a user does this, the solution would be to just clone the renamed one.

Screenshots

This screen share shows the behavior off if I wait for the app to detect the rename (which takes a little bit as it is just waiting on a periodic cycle behind the scenes).

Screen.Recording.2021-05-27.at.1.23.34.PM.mov

This screen share highlights that is in fact pointing to and updating the new repo.

Screen.Recording.2021-05-27.at.2.07.02.PM.mov

Release notes

Notes: [Fixed] Rename a repo and then create and clone a repo with that repo's previous name now points to a new repo not the renamed one.

@tidy-dev
tidy-dev requested a review from sergiou87 May 27, 2021 18:14

@sergiou87 sergiou87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fantastic 🕵️‍♀️  work!!! I love it 😍

Just one nit/question: why creating a new function instead of just adding the new parameter to the existing request?

I'm guessing that you didn't like having to pass 2 undefined values and then a true looks meh too… maybe a solution for the true could be renaming the parameter to cachePolicy and having an enum with two values: Default and Reload

What do you think?

@tidy-dev
tidy-dev merged commit 27ff797 into development May 28, 2021
@tidy-dev
tidy-dev deleted the reload-that-cache branch May 28, 2021 11:11
sergiou87 pushed a commit that referenced this pull request Jun 1, 2021
Reload HTTP fetch cache when cloning
@sergiou87 sergiou87 mentioned this pull request Jun 1, 2021
3 tasks done
@sergiou87 sergiou87 mentioned this pull request Jun 23, 2021
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.

GitHub Desktop names repository incorrectly and opens wrong repository

2 participants