Add vertical space
[tails/matsa.git] / vagrant / lib / vagrant_verified_download.rb
blobced681219ff62e5cec0e794ff5120f420d93f542
1 require 'digest'
2 require 'vagrant/util/downloader'
3 require 'vagrant/errors'
5 def check(path)
6   checksum = Digest::SHA256.new.file(path).hexdigest
7   if checksum != BOX_CHECKSUM
8     raise Vagrant::Errors::BoxVerificationFailed.new
9   end
10 end
12 module Vagrant
13   if vagrant_old
14     class Action::Box::Download
15       alias :unverified_download :download
16       def download
17         unverified_download
18         check(@temp_path)
19       end
20     end
21   else
22     class Util::Downloader
23       alias :unverified_download! :download!
24       def download!
25         unverified_download!
26         check(@destination)
27       end
28     end
29   end
30 end