Archive downloaded via V3 REST API is not real-time

I have been using github v3 rest api to download archive from my repo. But I found that when I download immediately after a new commit is pushed, the archive may not contain the newest commit.

Then I learned from the http response of API ‘get archive link’ that the download url is actually [https://codeload.github.com/[user]/[repo]/legacy.zip/branch]. So I tried to download the archive directly with browser and found error occurred sometimes.

For example:

Firstly I pushed a commit with id ‘1’ and then download, the archive is [user]-[repo]-1.zip and has the newest commit.

Secondly I pushed a commit with id ‘2’ and then download, the archive is [user]-[repo]-2.zip and has the newest commit.

But then I pushed a commit with id ‘3’ and then download, the downloaded archive is [user]-[repo]-1.zip and does not contain updates in commit ‘2’ and commit ‘3’.

I want to know if this is normal? Does github guarantee the downloaded archive is real-time? If not, do you have any work around to help me solve this problem because I need to ensure the downloaded files contain the newest commit.

Thanks in advance and looking forward to your replies.

1 Like

I encountered the same issue.

I found out that

https://github.com/:owner/:repo/archive/branch.tar.gz returns the real time file contents (compared hash with the archive that is downloaded using github.com interface). However, https://api.github.com/repos/:owner/:repo/:archive_format/:ref returns an outdated, the most recent release/tag’s archive.

The documentation suggests that it should be real-time for the branch Repositories - GitHub Docs
but seems that is not the case, or perhaps it is a bug.