Fixes #22 PUT request relies on request.body.length which passenger socket class does not contain (all other variants seems to) there is now implemented fallback based on reflection request.body.length then request.body.size and if all else fails request.content_length (which isn't ideal)

This commit is contained in:
Daniel Munn 2012-07-08 21:09:53 +01:00
parent c50ff70cba
commit 0bff9c36d1
3 changed files with 13 additions and 4 deletions

View File

@ -24,7 +24,7 @@ Redmine::Plugin.register :redmine_dmsf do
name "DMSF"
author "Vit Jonas / Daniel Munn"
description "Document Management System Features"
version "1.4.4p1 stable"
version "1.4.4p2 stable"
url "https://github.com/danmunn/redmine_dmsf"
author_url "https://code.google.com/p/redmine-dmsf/"

View File

@ -23,7 +23,8 @@ module RedmineDmsf
include ActionView::Helpers::NumberHelper
def initialize(*args)
raise NotFound if Setting.plugin_redmine_dmsf["dmsf_webdav"].empty?
webdav_setting = Setting.plugin_redmine_dmsf["dmsf_webdav"]
raise NotFound if !webdav_setting.nil? && webdav_setting.empty?
super(*args)
end

View File

@ -477,7 +477,6 @@ module RedmineDmsf
#
#
def put(request, response)
raise BadRequest if (collection?)
raise Forbidden unless User.current.admin? || User.current.allowed_to?(:file_manipulation, project)
@ -511,7 +510,16 @@ module RedmineDmsf
new_revision.comment = nil
new_revision.increase_version(2, true)
new_revision.mime_type = Redmine::MimeType.of(new_revision.name)
new_revision.size = request.body.length
# Phusion passenger does not have a method "length" in its model
# however includes a size method - so we instead use reflection
# to determine best approach to problem
if request.body.respond_to? 'length'
new_revision.size = request.body.length
elsif request.body.respond_to? 'size'
new_revision.size = request.body.size
else
new_revision.size = request.content_length #Bad Guess
end
raise InternalServerError unless new_revision.valid? && f.save
new_revision.disk_filename = new_revision.new_storage_filename