SubmissionsController: Send Content-Length if possible

This commit is contained in:
Sebastian Serth
2022-10-04 14:46:05 +02:00
parent c3daa51c8c
commit ca13ea03c8
2 changed files with 15 additions and 1 deletions

View File

@ -17,6 +17,8 @@ module CodeOcean
before_validation :hash_content, if: :content_present?
before_validation :set_ancestor_values, if: :incomplete_descendent?
attr_writer :size
belongs_to :context, polymorphic: true
belongs_to :file, class_name: 'CodeOcean::File', optional: true # This is only required for submissions and is validated below
alias ancestor file
@ -128,5 +130,13 @@ module CodeOcean
def visible
!hidden
end
def size
@size ||= if native_file?
native_file.size
else
content.size
end
end
end
end