[Title] Changed when getting snapshot infomation and added clearing list before update
authordonghyuk.yang <donghyuk.yang@samsung.com>
Wed, 22 Aug 2012 01:39:01 +0000 (10:39 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Wed, 22 Aug 2012 01:39:01 +0000 (10:39 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/pkg_server/client.rb

index 8d7e70b8534c1353100d7153d87cbae5401bf746..9061c80024ca2631df40f978bf67bb12aed0fa58 100644 (file)
@@ -74,6 +74,7 @@ class Client
         # chop server address, if end with "/"        
                if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
 
+               @snapshot_path = nil
                if is_snapshot_url(server_addr) then
                        @server_addr, @snapshot_path = split_addr_and_snapshot(server_addr) 
                else                    
@@ -103,20 +104,13 @@ class Client
            @log = logger
                end
 
-               $get_snapshot_mutex.synchronize {
-                       @snapshot_path = get_lastest_snapshot(@is_server_remote)
-               }                       
-               @log.info "The lastest snapshot : #{@snapshot_path}"
-               if @snapshot_path.nil? then 
-                       @log.warn "Failed to get the lastest package list"
-                       @snapshot_path = ""
-               end                     
-
         # read installed pkg list, and create hash
-        if not File.exist? @location then FileUtils.mkdir_p "#{@location}" end
+               if not File.exist? @location then FileUtils.mkdir_p "#{@location}" end
+               @log.info "Update local package list.. [#{@location}]"          
                read_installed_pkg_list()
 
                # read remote pkg list, and hash list
+               @log.info "Update remote package list and supported os list.." 
                update()
                @log.info "Initialize - #{server_addr}, #{location}"
        end
@@ -124,6 +118,18 @@ class Client
     public
     # update package list from server
     def update()
+               
+               if @snapshot_path.nil? then                     
+                       $get_snapshot_mutex.synchronize {
+                               @snapshot_path = get_lastest_snapshot(@is_server_remote)
+                       }                       
+               end                     
+               @log.info "The lastest snapshot : #{@snapshot_path}"
+               if @snapshot_path.nil? then 
+                       @log.warn "Failed to get the lastest package list"
+                       @snapshot_path = ""
+               end
+
                exists_snapshot = false
                if is_snapshot_exist(@snapshot_path) then 
                        @log.info "Snapshot information is already cached [#{get_pkglist_path()}]"                              
@@ -138,6 +144,8 @@ class Client
                        return false 
                end
 
+               clean_list()            
+
                if exists_snapshot then
                        read_supported_os_list(list_path)
                        read_remote_pkg_list(list_path)
@@ -179,6 +187,14 @@ class Client
         return true
        end
 
+       private
+       def clean_list()
+               @pkg_hash_os.clear
+               @archive_pkg_list.clear
+               @support_os_list.clear
+               @log.info "Cleard package list, supported os list.. OK"
+       end                     
+
     public
     # download package
     def download(pkg_name, os, trace, loc = nil)
@@ -1328,7 +1344,7 @@ class Client
                        cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size, os)
                end                     
                if not cached_filepath.nil? then
-                       @log.info "Install #{pkg_name} using cached file"                               
+                       @log.info "\"#{pkg_name}\" will be installed using cached file"                         
             ret = FileInstaller.install(pkg_name, cached_filepath, type, @location, @log)
                else
                        filepath = download(pkg_name, os, false, @download_path)