Skip to content

Commit

Permalink
Re-download if file changed using LATEST override option
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Dec 5, 2023
1 parent 14baf9b commit 31595c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/kotlin/GithubDownload.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class GithubDownload(val repo: String, val releaseVersion: String, val artifactR

println("Got URLs github:$repo:$version:$artifactRegexString $downloadURLs")

return downloadURLs.mapNotNull { Wget(it, targetDir) }
return downloadURLs
.mapNotNull { Wget(it, targetDir, updateIfChangedOnServer = forceLatest == GithubReleaseOverride.LATEST) }
}
}
12 changes: 10 additions & 2 deletions src/main/kotlin/commands/Wget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ import com.lordcodes.turtle.shellRun
import java.nio.file.Path

object Wget {
operator fun invoke(url: String, targetDir: Path): DownloadedItem? {
operator fun invoke(url: String, targetDir: Path, updateIfChangedOnServer: Boolean = false): DownloadedItem? {
val result = runCatching {
shellRun("wget", listOf("--no-clobber", url, "-P", targetDir.toString()))
shellRun(
"wget",
listOf(
if (updateIfChangedOnServer) "--timestamping" else "--no-clobber",
url,
"-P",
targetDir.toString()
)
)
}
return result.map {
val name = url.substringAfterLast("/")
Expand Down

0 comments on commit 31595c8

Please sign in to comment.