Fail the request if we clash files
Rather than make the file names incredibly long (by adding ms), just 500 it and expect the user to resend.
This commit is contained in:
parent
aae62ff94e
commit
6a40ad8a20
|
@ -37,6 +37,9 @@ func respond(code int, w http.ResponseWriter) {
|
|||
}
|
||||
|
||||
func gzipAndSave(data []byte, filepath string) error {
|
||||
if _, err := os.Stat(filepath); err == nil {
|
||||
return fmt.Errorf("file already exists") // the user can just retry
|
||||
}
|
||||
var b bytes.Buffer
|
||||
gz := gzip.NewWriter(&b)
|
||||
if _, err := gz.Write(data); err != nil {
|
||||
|
|
Loading…
Reference in New Issue