require "BuildComm"
require "FileTransferViaFTP"
require "FileTransferViaDirect"
+require 'digest'
$update_mutex = Mutex.new
downloaded_file_path = nil
begin
lock = Utils.file_lock(File.join(CONFIG_PATH,"cache_lock"))
- if Utils.is_linux_like_os( Utils::HOST_OS ) then
- cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
- if not cached_filepath.nil? then
- FileUtils.cp(cached_filepath, location)
- downloaded_file_path = File.join(location, File.basename(cached_filepath))
- end
+ cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
+ if not cached_filepath.nil? then
+ FileUtils.cp(cached_filepath, location)
+ downloaded_file_path = File.join(location, File.basename(cached_filepath))
end
rescue Exception => e
@log.error( e.message, Log::LV_USER)
cached_filepath = "#{@download_path}/#{pkg_filename}"
if File.exist? cached_filepath then
FileUtils.touch cached_filepath
- checksum = `sha256sum #{cached_filepath}`.split(" ")[0]
- size = `du -b #{cached_filepath}`.split[0].strip
- if checksum.eql? pkg_checksum and size.eql? pkg_size then
+ checksum = Digest::SHA256.file(cached_filepath).hexdigest
+ size = File.size cached_filepath
+ if checksum.to_s.eql? pkg_checksum and size.to_s.eql? pkg_size then
return cached_filepath
end
end