Fixed a bug that "Access denied" error is invoked on "windows" server 73/15773/1
authordonghee yang <donghee.yang@samsung.com>
Tue, 28 Jan 2014 03:26:03 +0000 (12:26 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Tue, 28 Jan 2014 03:26:03 +0000 (12:26 +0900)
[Description]

Change-Id: I743b2fe828b169a01ab7f7297846bb97e89a925c
Signed-off-by: donghee yang <donghee.yang@samsung.com>
src/pkg_server/client.rb

index 79d4658fd9667c5ccd0270f54c3cb4309c1b84c3..b3bf4dc51fef9b423a088211fdf4bbccda9330fe 100644 (file)
@@ -237,28 +237,25 @@ class Client
             @snapshot_path = ""
         end
 
-        exists_snapshot = false
-        if is_snapshot_exist(@snapshot_path) then
-            @log.info "Snapshot information is already cached [#{get_pkglist_path()}]"
-            exists_snapshot = true
-        else
-            @log.info "Snapshot information is not cached."
-        end
+        lock = nil
+        begin
+            lock = Utils.file_lock(File.join(CONFIG_PATH,".pkglist_cache_lock"))
 
-        list_path = get_pkglist_path()
-        if list_path.nil? then
-            @log.error "Failed to get package list path."
-            return false
-        end
+            exists_snapshot = false
+            if is_snapshot_exist(@snapshot_path) then
+                @log.info "Snapshot information is already cached [#{get_pkglist_path()}]"
+                exists_snapshot = true
+            else
+                @log.info "Snapshot information is not cached."
+            end
 
-        clean_list()
+            list_path = get_pkglist_path()
+            if list_path.nil? then
+                @log.error "Failed to get package list path."
+                return false
+            end
 
-        if exists_snapshot then
-            read_supported_os_list(list_path)
-            read_remote_pkg_list(list_path)
-            read_archive_pkg_list(list_path)
-        else
-            $update_mutex.synchronize do
+            if !exists_snapshot then
                 uniq_name = Utils.create_uniq_name
                 tmp_dir = File.join(@config_dist_path, uniq_name)
                 FileUtils.mkdir_p tmp_dir
@@ -266,24 +263,35 @@ class Client
                     @log.error "\"#{@server_addr}\" does not have supported os list file properly."
                     Utils.execute_shell("rm -rf #{tmp_dir}")
                     return false
-                else read_supported_os_list(tmp_dir) end
+                end
 
                 if not download_pkg_list(@is_server_remote, tmp_dir) then
                     @log.error "\"#{@server_addr}\" does not have package list file properly."
                     Utils.execute_shell("rm -rf #{tmp_dir}")
                     return false
-                else read_remote_pkg_list(tmp_dir) end
+                end
 
                 if not download_archive_pkg_list(@is_server_remote, tmp_dir) then
                     @log.error "\"#{@server_addr}\" does not have archive package list file properly. This error can be ignored"
-                else read_archive_pkg_list(tmp_dir)    end
+                end
+
                 Utils.execute_shell("mv #{tmp_dir} #{list_path}")
                 @log.info "Moved \"#{tmp_dir}\" to"
                 @log.info "  \"#{list_path}\""
+
                 # tmp_dir should be removed  whether mv command is failed
                 Utils.execute_shell("rm -rf #{tmp_dir}")
                 remove_snapshots()
             end
+
+            # load os/package infos
+            clean_list()
+            read_supported_os_list(list_path)
+            read_remote_pkg_list(list_path)
+            read_archive_pkg_list(list_path)
+
+        ensure
+            Utils.file_unlock(lock) if not lock.nil?
         end
 
         @log.info "Update package list from \"#{@server_addr}\".. OK"