Skip to content

Commit

Permalink
Only caches nim release for a day (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgomez authored Jan 1, 2025
1 parent 920793e commit 5d4d8db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit 5d4d8db

Please sign in to comment.