Skip to content

Commit 32ef13c

Browse files
committed
optimize fetch to use local download
if source is already downloaded and can be verified, skip downloading again.
1 parent b5ea0d6 commit 32ef13c

File tree

1 file changed

+7
-0
lines changed
  • lib/vanagon/component/source

1 file changed

+7
-0
lines changed

lib/vanagon/component/source/http.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ def initialize(url, sum:, workdir:, sum_type:, **options)
8282
# Download the source from the url specified. Sets the full path to the
8383
# file as @file and the @extension for the file as a side effect.
8484
def fetch
85+
@file = File.basename(URI.parse(@url).path)
86+
begin
87+
return if verify
88+
rescue RuntimeError, Errno::ENOENT
89+
remove_instance_variable(:@file)
90+
end
91+
8592
@file = download(@url)
8693
end
8794

0 commit comments

Comments
 (0)