$update_mutex = Mutex.new
$get_snapshot_mutex = Mutex.new
+$cache_mutex = Mutex.new
class Client
# constant
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(", ")}"
- begin
- lock = Utils.file_lock(File.join(CONFIG_PATH,"cache_lock"))
- FileUtils.rm_rf remove_list
- rescue Exception => e
- @log.error( e.message, Log::LV_USER)
- ensure
- Utils.file_unlock(lock)
+ $cache_mutex.synchronize do
+ FileUtils.rm_rf remove_list
end
end
end
private
def get_file_from_cache(filename, pkg_checksum, pkg_size, location)
downloaded_file_path = nil
- begin
- lock = Utils.file_lock(File.join(CONFIG_PATH,"cache_lock"))
- 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)
- ensure
- Utils.file_unlock(lock)
+ $cache_mutex.synchronize do
+ 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
end
if not downloaded_file_path.nil? and not File.exist? downloaded_file_path then
downloaded_file_path = nil