Editor: Allow file retrieval after code run

This commit is contained in:
Sebastian Serth
2022-10-04 15:17:16 +02:00
committed by Sebastian Serth
parent fb9672c7a4
commit 60078701f5
22 changed files with 311 additions and 8 deletions

View File

@ -58,7 +58,8 @@ class FileTree
disabled: !node.leaf?,
opened: !node.leaf?,
},
text: node.name,
text: name(node),
download_path: node.content.try(:download_path),
}
end
private :map_to_js_tree
@ -72,6 +73,17 @@ class FileTree
end
private :node_icon
def name(node)
# We just need any information that is only present in files retrieved from the runner's file system.
# In our case, that is the presence of the `privileged_execution` attribute.
if node.content.is_a?(CodeOcean::File) && !node.content.privileged_execution.nil?
node.content.name_with_extension_and_size
else
node.name
end
end
private :name
def to_js_tree
{
core: {