Skip to content

Commit

Permalink
perf(downloader): Return early from archive download for an empty rev…
Browse files Browse the repository at this point in the history
…ision

This avoids trying to download from an invalid archive URL, improving
the performance when running e.g. `ort download --dry-run`.

Note that the change in the static version of `toArchiveDownloadUrl()`
is only done for consistency.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Feb 19, 2024
1 parent 263b64d commit 13d7611
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion downloader/src/main/kotlin/VcsHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ enum class VcsHost(
*/
fun toArchiveDownloadUrl(vcsInfo: VcsInfo): String? {
val normalizedVcsInfo = vcsInfo.normalize()
if (normalizedVcsInfo.revision.isEmpty()) return null
val host = entries.find { it.isApplicable(normalizedVcsInfo) } ?: return null

return normalizedVcsInfo.url.toUri {
Expand Down Expand Up @@ -518,7 +519,7 @@ enum class VcsHost(
*/
fun toArchiveDownloadUrl(vcsInfo: VcsInfo): String? {
val normalizedVcsInfo = vcsInfo.normalize()
if (!isApplicable(normalizedVcsInfo)) return null
if (normalizedVcsInfo.revision.isEmpty() || !isApplicable(normalizedVcsInfo)) return null

return normalizedVcsInfo.url.toUri {
val userOrOrg = getUserOrOrgInternal(it) ?: return@toUri null
Expand Down

0 comments on commit 13d7611

Please sign in to comment.