From 6a40ad8a2073de4ae05f1b31cb9e3237ea776153 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Jan 2017 11:57:56 +0000 Subject: [PATCH] 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. --- scripts/rageshake.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/rageshake.go b/scripts/rageshake.go index 6ffd1476..51532890 100644 --- a/scripts/rageshake.go +++ b/scripts/rageshake.go @@ -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 {