[Title] remove linux dependent func ( du / sha256sum)
authorjiil.hyoun <jiil.hyoun@samsung.com>
Thu, 14 Mar 2013 09:20:49 +0000 (18:20 +0900)
committerjiil.hyoun <jiil.hyoun@samsung.com>
Thu, 14 Mar 2013 09:20:49 +0000 (18:20 +0900)
[Type] Feature
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: Ib99ca26f91465f855a4b030f9981cfff399ae870

src/pkg_server/client.rb

index a9a3b61a0921dd48be9f7aff1d97a925a99607d4..db0ac3e9504f77775e2de91cf9f3165909ba1649 100644 (file)
@@ -43,6 +43,7 @@ require "Version"
 require "BuildComm"
 require "FileTransferViaFTP"
 require "FileTransferViaDirect"
+require 'digest'
 
 
 $update_mutex = Mutex.new
@@ -344,12 +345,10 @@ class Client
                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)
@@ -402,9 +401,9 @@ class Client
                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