Skip to content

Commit

Permalink
Check for file size sanity in _archive_available
Browse files Browse the repository at this point in the history
It seems that if 'curl getsize' is called with an FTP URL that points
to a nonexistent file, it will return a size of -1 rather than throw
an error like it does with HTTP.

Fixes: https://trac.macports.org/ticket/53530
  • Loading branch information
jmroot committed Feb 14, 2017
1 parent b230d41 commit 6718cc6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/port1.0/portutil.tcl
Expand Up @@ -3296,7 +3296,9 @@ proc _archive_available {} {
append site [option archive.subdir]
}
set url [portfetch::assemble_url $site $archivename]
if {![catch {curl getsize $url} result]} {
# curl getsize can return -1 instead of throwing an error for
# nonexistent files on FTP sites.
if {![catch {curl getsize $url} size] && $size > 0} {
set archive_available_result 1
return 1
}
Expand Down

0 comments on commit 6718cc6

Please sign in to comment.