From: donghee yang Date: Wed, 20 Mar 2013 14:52:00 +0000 (+0900) Subject: [Title] Fixed download cache bug and job numbering bug X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38d1f13383e7aa44f5924ce6bf2dbcc8a71e8869;p=sdk%2Ftools%2Fsdk-build.git [Title] Fixed download cache bug and job numbering bug --- diff --git a/package/changelog b/package/changelog index 834a7e7..f7d1506 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,7 @@ +* 2.1.6 +- Fixed client cache bug +- Fixed Job numbering bug +== donghee yang 2013-03-20 * 2.1.5 - bug fix : log file remove when job initializing == hyoun jiil 2013-03-15 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index f6a68c1..8fae4d9 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,5 +1,5 @@ Source : dibs -Version :2.1.5 +Version :2.1.6 Maintainer : taejun ha, jiil hyoun , donghyuk yang , donghee yang , sungmin kim 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