fileSizesWithinMax checks that each file does not exceed the max allowed size.
(submitPaths []string)
| 396 | |
| 397 | // fileSizesWithinMax checks that each file does not exceed the max allowed size. |
| 398 | func (s submitValidator) fileSizesWithinMax(submitPaths []string) error { |
| 399 | for _, file := range submitPaths { |
| 400 | info, err := os.Stat(file) |
| 401 | if err != nil { |
| 402 | return err |
| 403 | } |
| 404 | const maxFileSize int64 = 65535 |
| 405 | if info.Size() >= maxFileSize { |
| 406 | msg := ` |
| 407 | |
| 408 | The submitted file '%s' is larger than the max allowed file size of %d bytes. |
| 409 | Please reduce the size of the file and try again. |
| 410 | |
| 411 | ` |
| 412 | return fmt.Errorf(msg, file, maxFileSize) |
| 413 | } |
| 414 | } |
| 415 | return nil |
| 416 | } |
| 417 | |
| 418 | // submissionNotEmpty checks that there is at least one file to submit. |
| 419 | func (s submitValidator) submissionNotEmpty(docs []workspace.Document) error { |