From 3b57d6ccf51ad1273fef5e629234f252104e1949 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Thu, 18 Feb 2016 09:52:24 +0100 Subject: [PATCH] Non-fatal MySQL error when migrating documents #504 --- lib/tasks/dmsf_convert_documents.rake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/tasks/dmsf_convert_documents.rake b/lib/tasks/dmsf_convert_documents.rake index 4210dc74..595661a6 100644 --- a/lib/tasks/dmsf_convert_documents.rake +++ b/lib/tasks/dmsf_convert_documents.rake @@ -3,7 +3,7 @@ # Redmine plugin for Document Management System "Features" # # Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2011-15 Karel Pičman +# Copyright (C) 2011-16 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -66,8 +66,13 @@ class DmsfConvertDocuments folder = DmsfFolder.new - folder.project = project - folder.user = document.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) + folder.project = project + attachment = document.attachments.reorder("#{Attachment.table_name}.created_on ASC").first + if attachment + folder.user = attachment.author + else + folder.user = Users.active.where(:admin => true).first + end folder.title = document.title folder.title.gsub!(/[\/\\\?":<>]/, '-') if replace