Non-fatal MySQL error when migrating documents #504

This commit is contained in:
Karel Picman 2016-02-18 09:52:24 +01:00
parent e7126d85d2
commit 3b57d6ccf5

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2011-15 Karel Pičman <karel.picman@kontron.com>
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -67,7 +67,12 @@ class DmsfConvertDocuments
folder = DmsfFolder.new
folder.project = project
folder.user = document.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author)
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