Skip to content
Snippets Groups Projects
Commit ffedafed authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

verify bitstreams in dspace for convert video worker

parent d3c5fee1
No related branches found
No related tags found
No related merge requests found
......@@ -7,13 +7,14 @@ class ConvertVideoWorker
def perform(id)
begin
object = learning_object_repository.find id
dspace_object = dspace_client.items.find(id: object.id_dspace, expand: 'bitstreams')
# convert if object has a flv and not a mp4
video = nil
object.attachments.each do |attachment|
video = attachment if attachment.name =~ /(.flv|.wmv|.mov|.mpg)$/i
dspace_object.bit_streams.each do |bitstream|
video = bitstream if bitstream.name =~ /(.flv|.wmv|.mov|.mpg)$/i
return true if attachment.name =~ /.mp4$/i
return true if bitstream.name =~ /.mp4$/i
end
return true if video.nil?
......@@ -48,11 +49,8 @@ class ConvertVideoWorker
ensure
# remove temp files
original_bitstream.unlink unless original_bitstream.nil?
unless converted.nil?
converted.close
FileUtils.rm converted_path, force: true
end
converted.close unless converted.nil?
FileUtils.rm converted_path, force: true
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment