1
0
Fork 0
mirror of https://github.com/Luzifer/tex-api.git synced 2024-11-08 08:10:09 +00:00

Pack only log and pdf

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-03-05 23:49:23 +01:00
parent c0323c8c62
commit 7a503be0fa
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 17 additions and 0 deletions

5
Godeps/Godeps.json generated
View file

@ -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",

12
main.go
View file

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