From b5348ab4b20c09770de5945f42a764ab81e20608 Mon Sep 17 00:00:00 2001 From: "COLA@Redminetest" Date: Wed, 2 Nov 2016 16:55:44 +0100 Subject: [PATCH] On PUT request, if previous revision size was 0 then just update that revision. --- lib/redmine_dmsf/webdav/dmsf_resource.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/redmine_dmsf/webdav/dmsf_resource.rb b/lib/redmine_dmsf/webdav/dmsf_resource.rb index 9421dd99..fe610318 100644 --- a/lib/redmine_dmsf/webdav/dmsf_resource.rb +++ b/lib/redmine_dmsf/webdav/dmsf_resource.rb @@ -272,7 +272,7 @@ module RedmineDmsf User.current.allowed_to?(:folder_manipulation, resource.project) if dest.exist? - methodNotAllowed + MethodNotAllowed # Files cannot be merged at this point, until a decision is made on how to merge them # ideally, we would merge revision history for both, ensuring the origin file wins with latest revision. else @@ -481,11 +481,16 @@ module RedmineDmsf if exist? # We're over-writing something, so ultimately a new revision f = file last_revision = file.last_revision - new_revision.source_revision = last_revision - if last_revision - new_revision.major_version = last_revision.major_version - new_revision.minor_version = last_revision.minor_version - new_revision.workflow = last_revision.workflow + if last_revision.size == 0 + new_revision = last_revision + new_revision.minor_version -= 1 + else + new_revision.source_revision = last_revision + if last_revision + new_revision.major_version = last_revision.major_version + new_revision.minor_version = last_revision.minor_version + new_revision.workflow = last_revision.workflow + end end else raise BadRequest unless (parent.projectless_path == '/' || (parent.exist? && parent.folder)) @@ -644,4 +649,4 @@ module RedmineDmsf end end -end \ No newline at end of file +end