Skip to content

Commit 7c30c6f

Browse files
authored
Merge branch 'master' into dependabot/bundler/nokogiri-1.19.3
2 parents 6210835 + f06b306 commit 7c30c6f

4 files changed

Lines changed: 87 additions & 3 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ gem 'bootsnap', '>= 1.16.0', require: false
3232
# Generates a terminal table
3333
gem 'tabulo', '~> 2.8.1'
3434

35-
gem 'jwt', '~> 2.7.0'
35+
gem 'jwt', '~> 3.2.0'
3636

3737
gem 'aws-sdk-cloudfront', '~> 1'
3838
gem 'aws-sdk-s3', '~> 1'

Gemfile.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ GEM
152152
reline (>= 0.4.2)
153153
jmespath (1.6.2)
154154
json (2.10.2)
155-
jwt (2.7.1)
155+
jwt (3.2.0)
156+
base64
156157
language_server-protocol (3.17.0.4)
157158
listen (3.9.0)
158159
rb-fsevent (~> 0.10, >= 0.10.3)
@@ -377,7 +378,7 @@ DEPENDENCIES
377378
factory_bot_rails
378379
faker
379380
fakeredis (~> 0.8)
380-
jwt (~> 2.7.0)
381+
jwt (~> 3.2.0)
381382
minitest
382383
minitest-stub_any_instance
383384
pg (~> 1.4.4)

lib/recording_importer.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ def self.import(filename, aws_client = nil)
7171
FileUtils.mv(directory, format_dir, force: true)
7272
end
7373
end
74+
rescue ActiveRecord::StatementInvalid
75+
# Let the connection-retry handler below deal with dropped DB connections
76+
raise
77+
rescue StandardError => e
78+
# Isolate per-format failures
79+
logger.warn("Skipping recording format from #{metadata_xml} due to import error: #{e.message}")
80+
next
7481
end
82+
7583
callback_data = CallbackData.find_by(meeting_id: recording.meeting_id)
7684
callback_data&.update(recording_id: recording.id)
7785
end
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# frozen_string_literal: true
2+
3+
require 'rails_helper'
4+
5+
RSpec.describe RecordingImporter do
6+
describe '.import' do
7+
let(:record_id) { "#{Digest::SHA256.hexdigest('meeting-1')}-1234567890123" }
8+
let(:work_dir) { Dir.mktmpdir }
9+
let(:publish_dir) { Dir.mktmpdir }
10+
11+
before do
12+
allow(Rails.configuration.x).to receive_messages(
13+
recording_work_dir: work_dir,
14+
recording_publish_dir: publish_dir,
15+
recording_unpublish_dir: publish_dir
16+
)
17+
allow(PostImporterScripts).to receive(:run)
18+
end
19+
20+
after do
21+
FileUtils.rm_rf([work_dir, publish_dir])
22+
end
23+
24+
it 'imports the other formats even when one format fails to import' do
25+
tar = build_tar
26+
27+
# Simulate the "video" format failing to import, without crafting broken metadata.
28+
allow(Recording).to receive(:create_from_metadata_xml).and_call_original
29+
allow(Recording).to receive(:create_from_metadata_xml)
30+
.with(a_string_including('<format>video</format>'))
31+
.and_raise(StandardError, 'simulated format failure')
32+
33+
expect { described_class.import(tar) }.not_to raise_error
34+
35+
recording = Recording.find_by(record_id: record_id)
36+
expect(recording).to be_present
37+
expect(recording.playback_formats.pluck(:format)).to contain_exactly('presentation')
38+
end
39+
40+
private
41+
42+
def metadata_xml(format:)
43+
<<~XML
44+
<?xml version="1.0" encoding="UTF-8"?>
45+
<recording>
46+
<id>#{record_id}</id>
47+
<state>published</state>
48+
<published>true</published>
49+
<meta>
50+
<meetingId>meeting-1</meetingId>
51+
<meetingName>Test Meeting</meetingName>
52+
</meta>
53+
<playback>
54+
<format>#{format}</format>
55+
<link>https://example.com/playback/#{format}/2.3/#{record_id}</link>
56+
</playback>
57+
</recording>
58+
XML
59+
end
60+
61+
# Builds a tar containing two valid formats: "presentation" and "video".
62+
def build_tar
63+
src = Dir.mktmpdir
64+
FileUtils.mkdir_p(File.join(src, 'presentation', record_id))
65+
File.write(File.join(src, 'presentation', record_id, 'metadata.xml'), metadata_xml(format: 'presentation'))
66+
67+
FileUtils.mkdir_p(File.join(src, 'video', record_id))
68+
File.write(File.join(src, 'video', record_id, 'metadata.xml'), metadata_xml(format: 'video'))
69+
70+
tar_path = File.join(Dir.mktmpdir, "#{record_id}.tar")
71+
Dir.chdir(src) { system('tar', '--create', '--file', tar_path, 'presentation', 'video') }
72+
tar_path
73+
end
74+
end
75+
end

0 commit comments

Comments
 (0)