[Title] package server update for using temp directory when uploading
authorhataejun <taejun.ha@samsung.com>
Wed, 5 Sep 2012 14:17:30 +0000 (23:17 +0900)
committerhataejun <taejun.ha@samsung.com>
Wed, 5 Sep 2012 14:17:30 +0000 (23:17 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/pkg_server/SocketRegisterListener.rb
src/pkg_server/client.rb

index 9d9755053b6a214b547db9c70a6a121922f31469..2ad78e3c23f192c647cb1d471848233014438d9c 100644 (file)
@@ -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
        
index 2c2fde8ccf0060d79b0948e03d17037f4ba02037..73c91a89f17fc1ba958e1f16125e149a63e33236 100644 (file)
@@ -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