Commit 9dc5d1a54068b2f1d01b1875a24cf58ef3e95c45

Authored by Antonio Terceiro
1 parent f09a9a5a

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 96 Dir.glob(File.join(attachments_dir, 'attachments', '*.xml')).each do |attachment_xml|
97 97 file = UploadedFile.new
98 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 103 puts "I: about to read data from #{file.filesystem_location} (xml: #{attachment_xml})"
100 104 file.uploaded_data = FileData.new(file.filesystem_location, file.filename, file.content_type)
101 105 file.parent = article
... ...