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

Only caches nim release for a day #1326

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/nimblepkg/downloadnim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,10 @@ proc getOfficialReleases*(options: Options): seq[Version] =
let oficialReleasesCachedFile =
options.nimbleDir.absolutePath() / "official-nim-releases.json"
if oficialReleasesCachedFile.fileExists():
return oficialReleasesCachedFile.readFile().parseJson().to(seq[Version])
#We only store the file for a day.
let fileCreation = getTime() - getFileInfo(oficialReleasesCachedFile).lastWriteTime
if fileCreation.inDays <= 1:
return oficialReleasesCachedFile.readFile().parseJson().to(seq[Version])
var parsedContents: JsonNode
try:
let rawContents = retrieveUrl(githubTagReleasesUrl.addGithubAuthentication())
Expand Down
1 change: 0 additions & 1 deletion tests/tnimbinaries.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ suite "Nim binaries":
var options = initOptions()
let releases = getOfficialReleases(options)
check releases.len > 0
check releases[^1] == newVersion("1.2.8")

test "can download a concrete version":
var options = initOptions()
Expand Down
Loading