Commit 99d79d1d authored by gubala's avatar gubala

support for spaces in folder names on prom

parent 58da6dae
......@@ -54,6 +54,7 @@ class ApplicationController < ActionController::Base
@path = params[:path]
@path.gsub!("gsiftp:/login01.prometheus.cyfronet.pl/", "prometheus/")
@path = "/#{@path}" unless @path.start_with?('/')
@unescaped_path = URI.unescape(@path).force_encoding('utf-8')
@path = URI.escape @path
end
......@@ -63,6 +64,11 @@ class ApplicationController < ActionController::Base
Plgdata::Application.config.prometheus_gridftp_host +
"/#{@path.gsub!('prometheus/', '')}"
end
if @unescaped_path.start_with?('/prometheus/') || @unescaped_path.start_with?('prometheus/')
@unescaped_path = "gsiftp://" +
Plgdata::Application.config.prometheus_gridftp_host +
"/#{@unescaped_path.gsub!('prometheus/', '')}"
end
end
def sanitize_filename(filename)
......
......@@ -33,18 +33,21 @@ class FilesController < ApplicationController
target_filename = sanitize_filename file.original_filename
if target_filename.present?
begin
logger.debug "Escaped path: #{@path}"
logger.debug "UNEscaped path: #{@unescaped_path}"
if is_blob
offset = request.headers['Content-Range'].split(' ')[1].to_i
data = file.read
logger.info "Executing PARTIAL put for [#{target_filename}], offset #{offset}, data size #{data.size}."
GFTP::PartialPut.new(data.size).partial_put @path + '/' + target_filename, @proxy, data, offset
GFTP::PartialPut.new(data.size).partial_put @unescaped_path + '/' + target_filename, @proxy, data, offset
else
logger.info "Executing NORMAL put for [#{target_filename}]."
GFTP::Put.new.put @path + '/' + target_filename, @proxy do |buf_size|
GFTP::Put.new.put @unescaped_path + '/' + target_filename, @proxy do |buf_size|
[ file.read(buf_size) || '', file.eof? ]
end
end
rescue GFTP::GlobusError => error
logger.warn error
error_message = (error.message.include?('500') ? error.message.split('500')[-2] : error.message)
error_message = I18n.t('upload.error') + ': ' + error_message
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment