* prevent file creating in case of error in conversion rake task
git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@157 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
parent
13659067a6
commit
ecbc773a55
@ -49,6 +49,7 @@ class DmsfConvertDocuments
|
||||
project.enabled_module_names = (project.enabled_module_names << "dmsf").uniq unless dry
|
||||
project.save! unless dry
|
||||
|
||||
fail = false
|
||||
folders = []
|
||||
project.documents.each do |document|
|
||||
puts "Processing document: " + document.title
|
||||
@ -83,6 +84,7 @@ class DmsfConvertDocuments
|
||||
rescue Exception => e
|
||||
puts "Creating folder: " + folder.title + " failed"
|
||||
puts e
|
||||
fail = true
|
||||
next
|
||||
end
|
||||
end
|
||||
@ -90,6 +92,7 @@ class DmsfConvertDocuments
|
||||
folders << folder;
|
||||
|
||||
files = []
|
||||
failed_files = []
|
||||
document.attachments.each do |attachment|
|
||||
begin
|
||||
file = DmsfFile.new
|
||||
@ -108,6 +111,12 @@ class DmsfConvertDocuments
|
||||
# File id is needed to properly generate revision disk filename
|
||||
file.name = DmsfFileRevision.remove_extension(file.name) + suffix + File.extname(file.name)
|
||||
|
||||
unless File.exist?(attachment.diskfile)
|
||||
puts "Creating file: " + attachment.filename + " failed, attachment file doesn't exist"
|
||||
fail = true
|
||||
next
|
||||
end
|
||||
|
||||
if dry
|
||||
puts "Dry check file: " + file.name
|
||||
if file.invalid?
|
||||
@ -162,13 +171,14 @@ class DmsfConvertDocuments
|
||||
rescue Exception => e
|
||||
puts "Creating file: " + attachment.filename + " failed"
|
||||
puts e
|
||||
fail = true
|
||||
end
|
||||
end
|
||||
|
||||
document.destroy unless dry
|
||||
document.destroy unless dry || fail
|
||||
|
||||
end
|
||||
project.enabled_module_names = project.enabled_module_names.reject {|mod| mod == "documents"} unless dry
|
||||
project.enabled_module_names = project.enabled_module_names.reject {|mod| mod == "documents"} unless dry || fail
|
||||
project.save! unless dry
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user