[Title] refactoring : info file variable change
authorhataejun <taejun.ha@samsung.com>
Sat, 18 Aug 2012 03:46:53 +0000 (12:46 +0900)
committerhataejun <taejun.ha@samsung.com>
Sat, 18 Aug 2012 03:46:53 +0000 (12:46 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/pkg_server/distribution.rb

index bbab453da2fd71da9d7f357a4a20cd4c482668b9..92752cae7178e66999b52de6eeef72e4d7e4f2cc 100644 (file)
@@ -37,6 +37,8 @@ class Distribution
     # constant
     PKG_LIST_FILE_PREFIX = "pkg_list_" 
        ARCHIVE_PKG_FILE = "archive_pkg_list"
+       OS_INFO_FILE = "os_info"
+       SNAPSHOT_INFO_FILE = "snapshot.info"
 
        def initialize( name, location, server_url, pkg_server )
 
@@ -46,8 +48,6 @@ class Distribution
                @log = pkg_server.log
                @integrity = pkg_server.integrity 
                @lock_file_name = "#{location}/.lock_file"
-               @os_info_file_path = "#{location}/os_info"
-               @snapshot_info_file_path = "#{location}/snapshot.info"
                @pkg_hash_os = {}  
                @archive_pkg_list = [] 
                @snapshot_hash = [] 
@@ -159,7 +159,7 @@ class Distribution
                        raise "snapshot temp file name already exist" 
                end 
 
-               FileUtils.copy_file( @snapshot_info_file_path, tmp_file_name )
+               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")}"
@@ -171,7 +171,7 @@ class Distribution
                        f.puts "path : /snapshots/#{name}"
                        f.puts
                end
-               FileUtils.mv( tmp_file_name, @snapshot_info_file_path, :force => true )
+               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)
@@ -251,7 +251,7 @@ class Distribution
                # update os information
                @support_os_list.push os
                @pkg_hash_os[os] = {} 
-               File.open(@os_info_file_path, "a") do |f|
+               File.open("#{@location}/#{OS_INFO_FILE}", "a") do |f|
                        f.puts os
                end
 
@@ -447,8 +447,8 @@ class Distribution
                end
 
                # modify info file 
-               info_file = File.readlines(@snapshot_info_file_path)
-               File.open(@snapshot_info_file_path, 'w') do |f|
+               info_file = File.readlines("#{@location}/#{SNAPSHOT_INFO_FILE}")
+               File.open("#{@location}/#{SNAPSHOT_INFO_FILE}", 'w') do |f|
                        remove_flag = false
                        info_file.each { |line|
                                if line =~ /name :/ then 
@@ -562,12 +562,12 @@ class Distribution
        end
 
        def initialize_pkg_list
-               if not File.exist? @os_info_file_path then 
+               if not File.exist? "#{@location}/#{OS_INFO_FILE}" then 
                        return
                end 
 
                # get support_os_list 
-               File.open( @os_info_file_path, "r" ) do |f|
+               File.open( "#{@location}/#{OS_INFO_FILE}", "r" ) do |f|
                        f.each_line do |l|
                                @support_os_list.push l.strip
                        end
@@ -679,13 +679,13 @@ class Distribution
        end
 
        def clean_snapshot_info_file(snapshot_list)
-               if not File.exist? @snapshot_info_file_path
+               if not File.exist? "#{@location}/#{SNAPSHOT_INFO_FILE}"
                        @log.error "Can not find snapshot info file"
                        return
                end 
 
                # modify snapshot info File
-               f = File.open(@snapshot_info_file_path, "r") 
+               f = File.open("#{@location}/#{SNAPSHOT_INFO_FILE}", "r") 
                info_lines = []
                save_flag = false
                f.each_line do |l|
@@ -703,7 +703,7 @@ class Distribution
                end
                f.close
 
-               f = File.open(@snapshot_info_file_path, "w") 
+               f = File.open("#{@location}/#{SNAPSHOT_INFO_FILE}", "w") 
                info_lines.each do |i|
                        f.puts i
                end