From 7194ae217d76436003ec03dab368c273ce3f2b5f Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Thu, 4 Jan 2018 11:14:16 -0700 Subject: [deps] update go.uuid to latest and include in vendor (#217) * Fix UUID issues (#216) * fixing errors due to new updates to uuid packakge * fix fomatting * updating vendored version of uuid package * adding test for more content types --- system/db/content.go | 6 +++++- system/db/upload.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/db/content.go b/system/db/content.go index e73d803..b96852e 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -203,7 +203,11 @@ func insert(ns string, data url.Values) (int, error) { data.Set("id", cid) // add UUID to data for use in embedded Item - uid := uuid.NewV4() + uid, err := uuid.NewV4() + if err != nil { + return err + } + data.Set("uuid", uid.String()) // if type has a specifier, add it to data for downstream processing diff --git a/system/db/upload.go b/system/db/upload.go index beeee2d..b7171dd 100644 --- a/system/db/upload.go +++ b/system/db/upload.go @@ -28,8 +28,13 @@ func SetUpload(target string, data url.Values) (int, error) { if data.Get("uuid") == "" || data.Get("uuid") == (uuid.UUID{}).String() { + // set new UUID for upload - data.Set("uuid", uuid.NewV4().String()) + uid, err := uuid.NewV4() + if err != nil { + return 0, err + } + data.Set("uuid", uid.String()) } if data.Get("slug") == "" { -- cgit v1.2.3 From c8640a82dd704ce51676a457b4a2ec72ec67e316 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 8 Jan 2018 08:31:03 -0800 Subject: Move defer statement into http handler function (#219) --- system/api/gzip.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/api/gzip.go b/system/api/gzip.go index be5a51b..02f1535 100644 --- a/system/api/gzip.go +++ b/system/api/gzip.go @@ -20,11 +20,13 @@ func Gzip(next http.HandlerFunc) http.HandlerFunc { if strings.Contains(req.Header.Get("Accept-Encoding"), "gzip") { // gzip response data res.Header().Set("Content-Encoding", "gzip") + gzWriter := gzip.NewWriter(res) + defer gzWriter.Close() var gzres gzipResponseWriter if pusher, ok := res.(http.Pusher); ok { - gzres = gzipResponseWriter{res, pusher, gzip.NewWriter(res)} + gzres = gzipResponseWriter{res, pusher, gzWriter} } else { - gzres = gzipResponseWriter{res, nil, gzip.NewWriter(res)} + gzres = gzipResponseWriter{res, nil, gzWriter} } next.ServeHTTP(gzres, req) @@ -43,7 +45,6 @@ type gzipResponseWriter struct { } func (gzw gzipResponseWriter) Write(p []byte) (int, error) { - defer gzw.gw.Close() return gzw.gw.Write(p) } -- cgit v1.2.3