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.
pull/3072/head
Kegan Dougal 2017-01-26 11:57:56 +00:00
parent aae62ff94e
commit 6a40ad8a20
1 changed files with 3 additions and 0 deletions

View File

@ -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 {