require "Version"
require "net/ftp"
$update_mutex = Mutex.new
-$update_os_mutex = Mutex.new
-$install_pkg_mutex = Mutex.new
+$get_snapshot_mutex = Mutex.new
class Client
# constant
@log = logger
end
- @snapshot_path = get_lastest_snapshot(@is_server_remote)
+ $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"
public
# update package list from server
def update()
-
exists_snapshot = false
if is_snapshot_exist(@snapshot_path) then
@log.info "Snapshot information is already cached [#{get_pkglist_path()}]"
if File.exist? local_file_path then
File.open(local_file_path, "r") do |f|
f.each_line do |l|
- @support_os_list.push(l.strip)
+ os = l.strip
+ if @support_os_list.index(os).nil? then @support_os_list.push(os) end
end
end
@log.info "Get supported os infomation.. OK"
if File.exist? local_file_path then
File.open(local_file_path, "r") do |f|
f.each_line do |l|
- @archive_pkg_list.push(l.strip)
+ pkg = l.strip
+ if @archive_pkg_list.index(pkg).nil? then @archive_pkg_list.push(pkg) end
end
end
@log.info "Get archive package infomation.. OK"