Add new CodeOcean::File#read method
* With a new method, we can simplify our code to handle differences between file.content and file.native_file.read
This commit is contained in:
@ -93,14 +93,10 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
end
|
||||
|
||||
local_file_path = local_path(file.filepath)
|
||||
if file.file_type.binary?
|
||||
FileUtils.cp(file.native_file.path, local_file_path)
|
||||
else
|
||||
begin
|
||||
File.write(local_file_path, file.content)
|
||||
rescue IOError => e
|
||||
raise Runner::Error::WorkspaceError.new("Could not create file #{file.filepath}: #{e.inspect}")
|
||||
end
|
||||
begin
|
||||
File.write(local_file_path, file.read)
|
||||
rescue IOError => e
|
||||
raise Runner::Error::WorkspaceError.new("Could not create file #{file.filepath}: #{e.inspect}")
|
||||
end
|
||||
end
|
||||
FileUtils.chmod_R('+rwtX', local_workspace_path)
|
||||
|
@ -116,7 +116,7 @@ class Runner::Strategy::Poseidon < Runner::Strategy
|
||||
copy = files.map do |file|
|
||||
{
|
||||
path: file.filepath,
|
||||
content: Base64.strict_encode64(file.content.presence || file.native_file.read || ''),
|
||||
content: Base64.strict_encode64(file.read || ''),
|
||||
}
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user