lib/daengine/teamsite_metadata_parser.rb in daengine-0.3.2 vs lib/daengine/teamsite_metadata_parser.rb in daengine-0.3.3
- old
+ new
@@ -94,20 +94,24 @@
da = DigitalAsset.find_or_initialize_by(guid: key)
if (!asset_docs.empty?)
assets[key]['documents_attributes'] = asset_docs
creating = da.new?
da.documents = []
- da.update_attributes!(assets[key])
+ begin
+ da.update_attributes!(assets[key])
+ rescue Exception => e
+ error_files << "#{e} ---- #{da.try(:guid)}, #{da.try(:errors).try(:full_messages)}"
+ end
creating ? added_count += 1 : update_count += 1
else
DigitalAsset.where(guid: key).try :delete_all
delete_count += 1
end
end
rescue Exception => e
- #puts "--**Exception**--- #{e}"
- error_files << "#{e} ---- #{da.try(:guid)}, #{da.try(:errors).try(:full_messages)}"
+ Daengine.log(e.message, "error")
+ Daengine.log(e.backtrace.join('\n'), "error")
end
end
log_txt = "TeamsiteMetadataParser: Failed to save/update following DigitalAssets in database:\n"
error_files.each do |asset_file|
log_txt << "> #{asset_file}\n"
@@ -124,19 +128,18 @@
asset_docs.each do |doc|
#exclude manifest_file
unless doc['path'].match('\/manifest\/')
file = File.join(path, doc['path'])
#exclude digital_asset_files that are not in *Teamsite Staging*
- if File::exist?(file)
+ if File.exist?(file)
docs << doc
if(File.mtime(file) > last_read)
begin
- exifdata = ::MiniExiftool.new file
+ exifdata = ::MiniExiftool.new("'#{file}'") # spaces in filename
doc['pages'] = exifdata.pagecount # or exifdata['Slides']
doc['size'] = exifdata.filesize
doc['mime_type'] = exifdata.mimetype
rescue Exception => e
- p "Error reading metadata from #{file} #{e.message}"
Daengine.log "Error reading metadata from #{file} #{e.message}", "error"
end
end
else
# the file was missing on disk, show a warning!
\ No newline at end of file