From 7a503be0fa48dddb6937f82a97462e2227a926f0 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 5 Mar 2017 23:49:23 +0100 Subject: [PATCH] Pack only log and pdf Signed-off-by: Knut Ahlers --- Godeps/Godeps.json | 5 +++++ main.go | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index c77f7bc..9134602 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -3,6 +3,11 @@ "GoVersion": "go1.8", "GodepVersion": "v79", "Deps": [ + { + "ImportPath": "github.com/Luzifer/go_helpers/str", + "Comment": "v2.1.0", + "Rev": "4206589520b9506841bb0fc67ab2278803b958ec" + }, { "ImportPath": "github.com/Luzifer/rconfig", "Comment": "v1.1.0", diff --git a/main.go b/main.go index d22a4e6..ab7595d 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( "strings" "time" + "github.com/Luzifer/go_helpers/str" "github.com/Luzifer/rconfig" log "github.com/Sirupsen/logrus" "github.com/gorilla/mux" @@ -242,6 +243,13 @@ func waitForJob(res http.ResponseWriter, r *http.Request) { http.Redirect(res, r, u.String(), http.StatusFound) } +func shouldPackFile(extension string) bool { + return str.StringInSlice(extension, []string{ + ".log", + ".pdf", + }) +} + func buildAssetsZIP(uid uuid.UUID) (io.Reader, error) { buf := new(bytes.Buffer) w := zip.NewWriter(buf) @@ -252,6 +260,10 @@ func buildAssetsZIP(uid uuid.UUID) (io.Reader, error) { return err } + if !shouldPackFile(path.Ext(info.Name())) { + return nil + } + zipInfo, err := zip.FileInfoHeader(info) if err != nil { return err