OS_INFO_FILE = "os_info"
SNAPSHOT_INFO_FILE = "snapshot.info"
LOCK_FILE = ".lock_file"
+ SYNC_LOCK_FILE = ".sync_lock_file"
def initialize( name, location, server_url, pkg_server )
@log = pkg_server.log
@integrity = pkg_server.integrity
@lock_file_path = "#{location}/#{LOCK_FILE}"
+ @sync_lock_file_path = "#{location}/#{SYNC_LOCK_FILE}"
@pkg_hash_os = {}
@archive_pkg_list = []
@snapshot_hash = []
FileUtils.copy_file( "#{snapshot_path}/#{ARCHIVE_PKG_FILE}",
"#{@location}/snapshots/#{name}/#{ARCHIVE_PKG_FILE}" )
- # copy os info file
- FileUtils.copy_file( "#{snapshot_path}/#{OS_INFO_FILE}",
- "#{@location}/snapshots/#{name}/#{OS_INFO_FILE}" )
-
- # generate temp file
- tmp_file_name = ""
- while ( tmp_file_name.empty? )
- tmp_file_name = @location + "/temp/." + Utils.create_uniq_name
-
- if File.exist? tmp_file_name then
- tmp_file_name = ""
- end
- end
-
- FileUtils.copy_file( "#{@location}/#{SNAPSHOT_INFO_FILE}", tmp_file_name )
- File.open( tmp_file_name, "a" ) do |f|
- f.puts "name : #{name}"
- f.puts "time : #{Time.now.strftime("%Y%m%d%H%M%S")}"
- if from_cmd then
- f.puts "type : manual"
- else
- f.puts "type : auto"
- end
- f.puts "path : /snapshots/#{name}"
- f.puts
- end
- FileUtils.mv( tmp_file_name, "#{@location}/#{SNAPSHOT_INFO_FILE}", :force => true )
-
- # snapshot is generated
- @log.output( "snapshot is generated : #{@location}/snapshots/#{name}", Log::LV_USER)
- return name
+ # copy os info file
+ FileUtils.copy_file( "#{snapshot_path}/#{OS_INFO_FILE}",
+ "#{@location}/snapshots/#{name}/#{OS_INFO_FILE}" )
+
+ # generate temp file
+ tmp_file_name = ""
+ while ( tmp_file_name.empty? )
+ tmp_file_name = @location + "/temp/." + Utils.create_uniq_name
+
+ if File.exist? tmp_file_name then
+ tmp_file_name = ""
+ end
+ end
+
+ FileUtils.copy_file( "#{@location}/#{SNAPSHOT_INFO_FILE}", tmp_file_name )
+ File.open( tmp_file_name, "a" ) do |f|
+ f.puts "name : #{name}"
+ f.puts "time : #{Time.now.strftime("%Y%m%d%H%M%S")}"
+ if from_cmd then
+ f.puts "type : manual"
+ else
+ f.puts "type : auto"
+ end
+ f.puts "path : /snapshots/#{name}"
+ f.puts
+ end
+ FileUtils.mv( tmp_file_name, "#{@location}/#{SNAPSHOT_INFO_FILE}", :force => true )
+
+ # snapshot is generated
+ @log.output( "snapshot is generated : #{@location}/snapshots/#{name}", Log::LV_USER)
+ return name
end
def sync(force, snapshot = "")
archive_update_flag = false
distribution_update_flag = false
changes = []
+
+ # lock
+ sync_lock_file = Utils.file_lock(@sync_lock_file_path)
# reload pkg list from newest pkg list file
reload_distribution_information()
# unlock
Utils.file_unlock(lock_file)
+ Utils.file_unlock(sync_lock_file)
if not changes.empty? then
@last_sync_changes = "SYSTEM: sync parents server \n#{changes.uniq.join("\n\n")}"