@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"
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
end
}
+ if not dock_name.empty? then
+ FileUtils.rm_rf "#{@parent_server.incoming_path}/#{dock_name}"
+ end
+
BuildCommServer.send_end(req)
end
return nil
end
+ # create unique dock number
+ dock = Utils.create_uniq_name()
+
# upload file
binary_list = []
binary_path_list.each do |bpath|
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
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