fix: pasting a component with image isn't working (#37529)

- when copying a component that has image in it, and we try to paste it. Image URL
appends  `static_None`. Result in crash or image not found error.
- In this commit we have fixed this scenario, copy paste is working for components
containing images.

---------

Co-authored-by: Muhammad Faraz  Maqsood <faraz.maqsood@A006-01130.local>
This commit is contained in:
Muhammad Faraz Maqsood
2025-10-24 20:12:45 +05:00
committed by GitHub
parent 6dc868831c
commit 8f7e8e3a8b

View File

@@ -745,10 +745,10 @@ def _import_file_into_course(
if thumbnail_content is not None:
content.thumbnail_location = thumbnail_location
contentstore().save(content)
return True, {clipboard_file_path: f"static/{import_path}"}
return True, {clipboard_file_path: filename if not import_path else f"static/{import_path}"}
elif current_file.content_digest == file_data_obj.md5_hash:
# The file already exists and matches exactly, so no action is needed except substitutions
return None, {clipboard_file_path: f"static/{import_path}"}
# The file already exists and matches exactly, so no action is needed
return None, {}
else:
# There is a conflict with some other file that has the same name.
return False, {}