comparison pkg/controllers/srimports.go @ 4875:6237e6165041

* Raise the upload limit for sounding results from 25GB up to 50GB. * Issue an error if sounding results uploads are over the limit instead of silently truncating them. * Fix a file handle leak when storing all uploads.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 31 Jan 2020 23:17:37 +0100
parents 4394daeea96a
children 85f19e924a43
comparison
equal deleted inserted replaced
4874:7cbe5d32a614 4875:6237e6165041
38 mw "gemma.intevation.de/gemma/pkg/middleware" 38 mw "gemma.intevation.de/gemma/pkg/middleware"
39 ) 39 )
40 40
41 const ( 41 const (
42 soundingResultName = "soundingresult" 42 soundingResultName = "soundingresult"
43 maxSoundingResultSize = 25 * 1024 * 1024 43 maxSoundingResultSize = 50 * 1024 * 1024
44 ) 44 )
45 45
46 func fetchSoundingResult(req *http.Request) (string, error) { 46 func fetchSoundingResult(req *http.Request) (string, error) {
47 47
48 // Check first if we have a token. 48 // Check first if we have a token.
61 return "", err 61 return "", err
62 } 62 }
63 return dst, nil 63 return dst, nil
64 } 64 }
65 65
66 return misc.StoreUploadedFile( 66 return misc.StoreUploadedFileCheck(
67 req, 67 req,
68 soundingResultName, 68 soundingResultName,
69 "sr.zip", 69 "sr.zip",
70 maxSoundingResultSize, 70 maxSoundingResultSize,
71 true,
71 ) 72 )
72 } 73 }
73 74
74 func fetchSoundingResultMetaOverrides(sr *imports.SoundingResult, req *http.Request) error { 75 func fetchSoundingResultMetaOverrides(sr *imports.SoundingResult, req *http.Request) error {
75 76
192 } 193 }
193 194
194 func uploadSoundingResult(req *http.Request) (jr mw.JSONResult, err error) { 195 func uploadSoundingResult(req *http.Request) (jr mw.JSONResult, err error) {
195 196
196 var dir string 197 var dir string
197 if dir, err = misc.StoreUploadedFile( 198 if dir, err = misc.StoreUploadedFileCheck(
198 req, 199 req,
199 soundingResultName, 200 soundingResultName,
200 "sr.zip", 201 "sr.zip",
201 maxSoundingResultSize, 202 maxSoundingResultSize,
203 true,
202 ); err != nil { 204 ); err != nil {
203 return 205 return
204 } 206 }
205 207
206 var messages []string 208 var messages []string