From: hataejun Date: Wed, 5 Sep 2012 14:17:30 +0000 (+0900) Subject: [Title] package server update for using temp directory when uploading X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27070d4b52eaaaaa1f606bf626e0bbdc84654691;p=sdk%2Ftools%2Fsdk-build.git [Title] package server update for using temp directory when uploading [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/src/pkg_server/SocketRegisterListener.rb b/src/pkg_server/SocketRegisterListener.rb index 9d97550..2ad78e3 100644 --- a/src/pkg_server/SocketRegisterListener.rb +++ b/src/pkg_server/SocketRegisterListener.rb @@ -109,8 +109,18 @@ class SocketRegisterListener @log.info "Received File transfer REQ : #{line}" BuildCommServer.send_begin(req) - begin + + tok = line.split("|").map { |x| x.strip } + if tok.count > 1 then + dock_name = tok[1].strip + incoming_dir = "#{@parent_server.incoming_path}/#{dock_name}" + FileUtils.mkdir_p(incoming_dir) + else incoming_dir = "#{@parent_server.incoming_path}" + end + + file_path_list = [] + begin @comm_server.receive_file(req, incoming_dir) rescue => e @log.error "Failed to transfer file" @@ -133,14 +143,24 @@ class SocketRegisterListener end dist_name = tok[1].strip + if tok[2].start_with? "DOCK" then + dock_name = tok[3] + idx = 4 + else + dock_name = "" + idx = 2 + end + file_path_list = [] - idx = 2 while idx < tok.length do - file_path_list.push "#{@parent_server.incoming_path}/#{tok[idx]}" + if dock_name.empty? then + file_path_list.push "#{@parent_server.incoming_path}/#{tok[idx]}" + else + file_path_list.push "#{@parent_server.incoming_path}/#{dock_name}/#{tok[idx]}" + end idx = idx + 1 end - # register mutex $register_mutex.synchronize { begin @@ -157,6 +177,10 @@ class SocketRegisterListener end } + if not dock_name.empty? then + FileUtils.rm_rf "#{@parent_server.incoming_path}/#{dock_name}" + end + BuildCommServer.send_end(req) end diff --git a/src/pkg_server/client.rb b/src/pkg_server/client.rb index 2c2fde8..73c91a8 100644 --- a/src/pkg_server/client.rb +++ b/src/pkg_server/client.rb @@ -343,6 +343,9 @@ class Client return nil end + # create unique dock number + dock = Utils.create_uniq_name() + # upload file binary_list = [] binary_path_list.each do |bpath| @@ -355,7 +358,7 @@ class Client end @log.info "Send ready REQ.. [UPLOAD]" - result = client.send("UPLOAD") + result = client.send("UPLOAD|#{dock}") if not result then @log.error "Failed to send ready REQ.." return nil @@ -388,9 +391,9 @@ class Client return nil end - @log.info "Send register message.. [REGISTER|#{dist}|#{binary_list.join("|")}]" + @log.info "Send register message.. [REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}]" snapshot = nil - if client.send "REGISTER|#{dist}|#{binary_list.join("|")}" then + if client.send "REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}" then output = client.read_lines do |l| line = l.split("|") if line[0].strip == "ERROR" then