[Title] Fixed download cache bug and job numbering bug
authordonghee yang <donghee.yang@samsung.com>
Wed, 20 Mar 2013 14:52:00 +0000 (23:52 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Wed, 20 Mar 2013 14:52:00 +0000 (23:52 +0900)
package/changelog
package/pkginfo.manifest
src/pkg_server/client.rb

index 834a7e79a989d6b04d6571e544aa92c559e21cf4..f7d15062cc7c7c4190a1e79a9005c9baa1dd1cd8 100644 (file)
@@ -1,3 +1,7 @@
+* 2.1.6
+- Fixed client cache bug
+- Fixed Job numbering bug
+== donghee yang <donghee.yang@samsung.com> 2013-03-20
 * 2.1.5
 - bug fix : log file remove when job initializing 
 == hyoun jiil <jiil.hyoun@samsung.com> 2013-03-15
index f6a68c17f69443cd0d2905619e7753b54c6b877a..8fae4d90491bac431e48d95510d84c22ede73366 100644 (file)
@@ -1,5 +1,5 @@
 Source : dibs
-Version :2.1.5
+Version :2.1.6
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, donghyuk yang <donghyouk.yang@samsung.com>, donghee yang <donghee.yang@samsung.com>, sungmin kim <dev.sungmin.kim@samsung.com
 
 Package : dibs
index 575527dc19b077e6d1adaafdacbd2c885b3afe76..f64970591060f86d730a30066f82ac99df9fbc8d 100644 (file)
@@ -134,42 +134,40 @@ class Client
                read_installed_pkg_list()
 
                @configs = {}
-               #default cache size = 4G
-               @configs[:CACHE_SIZE] = "4000"
+               #default cache size = 8G
+               @configs[:CACHE_SIZE] = "8000"
        end
 
 
        # make cache clean
-       #private
-       #def remove_old_files_in_cache
-       #       #get dir info
-       #       cache_list = get_cache_dir_list
-       #       cache_info_list = Utils.get_sub_files_info(cache_list).sort {|a,b| a[3] <=> b[3]} # [path,size,ctime,mtime]
-       #       cache_size = 0
-       #       cache_info_list.each {|file| cache_size += file[1]}
-
-       #       read_configs
-       #       max_cache_size = get_config_max_cache_size
-
-       #       extra_size = cache_size - max_cache_size
-
-       #       if extra_size < 0 then return end
-
-       #       remove_list = []
-       #       while extra_size > 0 do
-       #               old_package = cache_info_list.shift
-       #               remove_list.push old_package[0]
-       #               extra_size -= old_package[1]
-       #       end
-
-       #       if not remove_list.empty? then
-       #               @log.info "Removed oldest package files.. (Now not fully caching)"
-       #               @log.info "  * #{remove_list.map{|path| File.basename(path)}.join(", ")}"
-       #               $cache_mutex.synchronize do
-       #                       FileUtils.rm_rf remove_list
-       #               end
-       #       end
-       #end
+       private
+       def remove_old_files_in_cache
+               #get dir info
+               cache_list = get_cache_dir_list
+               cache_info_list = Utils.get_sub_files_info(cache_list).sort {|a,b| a[3] <=> b[3]} # [path,size,ctime,mtime]
+               cache_size = 0
+               cache_info_list.each {|file| cache_size += file[1]}
+
+               read_configs
+               max_cache_size = get_config_max_cache_size
+
+               extra_size = cache_size - max_cache_size
+
+               if extra_size < 0 then return end
+
+               remove_list = []
+               while extra_size > 0 do
+                       old_package = cache_info_list.shift
+                       remove_list.push old_package[0]
+                       extra_size -= old_package[1]
+               end
+
+               if not remove_list.empty? then
+                       @log.info "Removed oldest package files.. (Now not fully caching)"
+                       @log.info "  * #{remove_list.map{|path| File.basename(path)}.join(", ")}"
+                       FileUtils.rm_rf remove_list
+               end
+       end
 
        private
        def get_cache_dir_list
@@ -178,7 +176,7 @@ class Client
 
        private
        def get_config_max_cache_size
-               return (@configs[:CACHE_SIZE] =~ /^([0-9][0-9]*)$/i)?  ($1.to_i * 1024 * 1024)  :  (4 * 1024 * 1024 * 1024) #default size 4G : unit = MB
+               return (@configs[:CACHE_SIZE] =~ /^([0-9][0-9]*)$/i)?  ($1.to_i * 1024 * 1024)  :  (8 * 1024 * 1024 * 1024) #default size 4G : unit = MB
        end
 
        private
@@ -349,13 +347,16 @@ class Client
                if not File.directory? location then return nil end
                downloaded_file_path = nil
                @log.info "Wait for cache sync",Log::LV_USER
-               $cache_mutex.synchronize do
+               begin
+                       lock = Utils.file_lock(File.join(CONFIG_PATH,".cache_lock"))
                        @log.info "Entering cache sync",Log::LV_USER
                        cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
                        if not cached_filepath.nil? and File.exist? cached_filepath then
                                FileUtils.ln(cached_filepath, location, :force => true)
                                downloaded_file_path = File.join(location, File.basename(cached_filepath))
                        end
+               ensure
+                       Utils.file_unlock(lock) if not lock.nil?
                end
                @log.info "Cache sync done",Log::LV_USER
                if not downloaded_file_path.nil? and not File.exist? downloaded_file_path then
@@ -383,7 +384,14 @@ class Client
                        @log.info "Failed to move [#{filename}] to "
                        @log.info "  [#{@download_path}]"
                end
-               #remove_old_files_in_cache
+
+               begin
+                       lock = Utils.file_lock(File.join(CONFIG_PATH,".cache_lock"))
+
+                       remove_old_files_in_cache
+               ensure 
+                       Utils.file_unlock(lock) if not lock.nil?
+               end
        end
 
        private