mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
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 {
|
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
|
var b bytes.Buffer
|
||||||
gz := gzip.NewWriter(&b)
|
gz := gzip.NewWriter(&b)
|
||||||
if _, err := gz.Write(data); err != nil {
|
if _, err := gz.Write(data); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user