#716 dav4rack -> planio/dav4rack
This commit is contained in:
parent
43077c2851
commit
7cee335e13
@ -42,24 +42,23 @@ module RedmineDmsf
|
||||
def call(env)
|
||||
begin
|
||||
status, headers, body = @dav_app.call env
|
||||
# If the URL map generated by Rack::Builder did not find a matching path,
|
||||
# it will return a 404 along with the X-Cascade header set to 'pass'.
|
||||
if status == 404 and headers['X-Cascade'] == 'pass'
|
||||
# The MS web redirector webdav client likes to go up a level and try
|
||||
# OPTIONS there. We catch that here and respond telling it that just
|
||||
# plain HTTP is going on.
|
||||
if 'OPTIONS'.casecmp(env['REQUEST_METHOD'].to_s) == 0
|
||||
[ '200', { 'Allow' => 'OPTIONS,HEAD,GET,PUT,POST,DELETE' }, [''] ]
|
||||
else
|
||||
# let Rails handle the request
|
||||
@rails_app.call env
|
||||
end
|
||||
else
|
||||
[status, headers, body]
|
||||
end
|
||||
rescue Exception => e
|
||||
# let Rails handle the request
|
||||
@rails_app.call env
|
||||
Rails.logger.error e.message
|
||||
end
|
||||
# If the URL map generated by Rack::Builder did not find a matching path,
|
||||
# it will return a 404 along with the X-Cascade header set to 'pass'.
|
||||
if status == 404 and headers['X-Cascade'] == 'pass'
|
||||
# The MS web redirector webdav client likes to go up a level and try
|
||||
# OPTIONS there. We catch that here and respond telling it that just
|
||||
# plain HTTP is going on.
|
||||
if 'OPTIONS'.casecmp(env['REQUEST_METHOD'].to_s) == 0
|
||||
[ '200', { 'Allow' => 'OPTIONS,HEAD,GET,PUT,POST,DELETE' }, [''] ]
|
||||
else
|
||||
# let Rails handle the request
|
||||
@rails_app.call env
|
||||
end
|
||||
else
|
||||
[status, headers, body]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -662,7 +662,8 @@ module RedmineDmsf
|
||||
# implementation of service for request, which allows for us to pipe a single file through
|
||||
# also best-utilising DAV4Rack's implementation.
|
||||
def download
|
||||
raise NotFound unless (file && file.last_revision && file.last_revision.disk_file(false))
|
||||
disk_file = file.last_revision.disk_file
|
||||
raise NotFound unless (file && file.last_revision && disk_file && File.exist?(disk_file))
|
||||
raise Forbidden unless (!parent.exist? || !parent.folder || DmsfFolder.permissions?(parent.folder))
|
||||
# If there is no range (start of ranged download, or direct download) then we log the
|
||||
# file access, so we can properly keep logged information
|
||||
@ -673,7 +674,7 @@ module RedmineDmsf
|
||||
access.action = DmsfFileRevisionAccess::DownloadAction
|
||||
access.save!
|
||||
end
|
||||
File.new(file.last_revision.disk_file)
|
||||
File.new disk_file
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user