#716 dav4rack -> planio/dav4rack

This commit is contained in:
Karel Picman 2018-01-31 14:13:39 +01:00
parent 43077c2851
commit 7cee335e13
2 changed files with 19 additions and 19 deletions

View File

@ -42,6 +42,9 @@ module RedmineDmsf
def call(env)
begin
status, headers, body = @dav_app.call env
rescue Exception => e
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'
@ -57,10 +60,6 @@ module RedmineDmsf
else
[status, headers, body]
end
rescue Exception => e
# let Rails handle the request
@rails_app.call env
end
end
end

View File

@ -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