Skip to content

Commit ce4f03c

Browse files
committed
try even harder to resolve references in common cartridge
try to add referenced files to the course even if they weren't included in the manifest test plan: * import the common cartridge package referenced in the ticket * all the images should be resolved closes #CNVS-30619 Change-Id: I0287dcbbdf6eb7f1de9f849d4094738594e4e8a4 Reviewed-on: https://gerrit.instructure.com/86668 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
1 parent b2d203b commit ce4f03c

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

lib/cc/importer/standard/converter.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,22 @@ def process_variants
9191
end
9292

9393
def find_file_migration_id(path)
94-
@file_path_migration_id[path] || @file_path_migration_id[path.gsub(%r{\$[^$]*\$|\.\./}, '')] ||
94+
mig_id = @file_path_migration_id[path] || @file_path_migration_id[path.gsub(%r{\$[^$]*\$|\.\./}, '')] ||
9595
@file_path_migration_id[path.gsub(%r{\$[^$]*\$|\.\./}, '').sub(WEB_RESOURCES_FOLDER + '/', '')]
96+
97+
unless mig_id
98+
full_path = File.expand_path(File.join(@unzipped_file_path, path))
99+
100+
if full_path.start_with?(File.expand_path(@unzipped_file_path)) && File.exists?(full_path)
101+
# try to make it work even if the file wasn't technically included in the manifest :/
102+
mig_id = Digest::MD5.hexdigest(path)
103+
file = {:path_name => path, :migration_id => mig_id,
104+
:file_name => File.basename(path), :type => 'FILE_TYPE'}
105+
add_course_file(file)
106+
end
107+
end
108+
109+
mig_id
96110
end
97111

98112
def get_canvas_att_replacement_url(path, resource_dir=nil)
@@ -103,7 +117,7 @@ def get_canvas_att_replacement_url(path, resource_dir=nil)
103117
end
104118
path = path[1..-1] if path.start_with?('/')
105119
mig_id = nil
106-
if resource_dir
120+
if resource_dir && resource_dir != "."
107121
mig_id = find_file_migration_id(File.join(resource_dir, path))
108122
end
109123
mig_id ||= find_file_migration_id(path)

0 commit comments

Comments
 (0)