Commit 9dc5d1a54068b2f1d01b1875a24cf58ef3e95c45
1 parent
f09a9a5a
Exists in
master
and in
29 other branches
ActionItem305: resist unexisting attachment
Showing
1 changed file
with
4 additions
and
0 deletions
Show diff stats
script/import-cooperation.net
@@ -96,6 +96,10 @@ for username in ARGV | @@ -96,6 +96,10 @@ for username in ARGV | ||
96 | Dir.glob(File.join(attachments_dir, 'attachments', '*.xml')).each do |attachment_xml| | 96 | Dir.glob(File.join(attachments_dir, 'attachments', '*.xml')).each do |attachment_xml| |
97 | file = UploadedFile.new | 97 | file = UploadedFile.new |
98 | file.from_xml(File.read(attachment_xml)) | 98 | file.from_xml(File.read(attachment_xml)) |
99 | + if !File.exist?(file.filesystem_location) | ||
100 | + puts "W: skipping attachment pointing to unexisting file" | ||
101 | + next | ||
102 | + end | ||
99 | puts "I: about to read data from #{file.filesystem_location} (xml: #{attachment_xml})" | 103 | puts "I: about to read data from #{file.filesystem_location} (xml: #{attachment_xml})" |
100 | file.uploaded_data = FileData.new(file.filesystem_location, file.filename, file.content_type) | 104 | file.uploaded_data = FileData.new(file.filesystem_location, file.filename, file.content_type) |
101 | file.parent = article | 105 | file.parent = article |