Commit 58839cef authored by Christopher Speller's avatar Christopher Speller Committed by GitHub

Upgrading server dependancies (#6984)

parent e2f4492e
......@@ -19,7 +19,6 @@ import (
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"strings"
"sync"
......@@ -114,8 +113,12 @@ func MoveFile(oldPath, newPath string) *model.AppError {
}
bucket := utils.Cfg.FileSettings.AmazonS3Bucket
var copyConds = s3.NewCopyConditions()
if err = s3Clnt.CopyObject(bucket, newPath, "/"+path.Join(bucket, oldPath), copyConds); err != nil {
source := s3.NewSourceInfo(bucket, oldPath, nil)
destination, err := s3.NewDestinationInfo(bucket, newPath, nil, nil)
if err != nil {
return model.NewLocAppError("moveFile", "api.file.write_file.s3.app_error", nil, err.Error())
}
if err = s3Clnt.CopyObject(destination, source); err != nil {
return model.NewLocAppError("moveFile", "api.file.move_file.delete_from_s3.app_error", nil, err.Error())
}
if err = s3Clnt.RemoveObject(bucket, oldPath); err != nil {
......@@ -489,7 +492,7 @@ func HandleImages(previewPathList []string, thumbnailPathList []string, fileData
go func(img *image.Image, path string, width int, height int) {
defer wg.Done()
generateThumbnailImage(*img, path, width, height)
}(img,thumbnailPathList[i], width, height)
}(img, thumbnailPathList[i], width, height)
go func(img *image.Image, path string, width int) {
defer wg.Done()
......
hash: 4c29ee4e38944411744a2a1af3e71836591d28feea24b328ab3d440a9ad1cef0
updated: 2017-06-23T08:58:13.944294825-04:00
hash: f60c88d60d742c881b0b746018ba7954884c3b53ff4affe89aaadd29fb1cb328
updated: 2017-07-19T08:52:10.191163881-07:00
imports:
- name: github.com/alecthomas/log4go
version: 3fbce08846379ec7f4f6bc7fce6dd01ce28fae4c
......@@ -17,13 +17,15 @@ imports:
- name: github.com/dimchansky/utfbom
version: 6c6132ff69f0f6c088739067407b5d32c52e1d0f
- name: github.com/disintegration/imaging
version: ac27d1805a555e1754fa177216ee07f4e63c30b5
version: 1b5cf1a92e375a4574a8214eb877fc3f721a612d
- name: github.com/dyatlov/go-opengraph
version: 41a3523719dfbe7e8f853fbd4061867543db5270
subpackages:
- opengraph
- name: github.com/fsnotify/fsnotify
version: 629574ca2a5df945712d3079857300b5e4da0236
- name: github.com/go-ini/ini
version: 3d73f4b845efdf9989fffd4b4e562727744a34ba
- name: github.com/go-ldap/ldap
version: 8168ee085ee43257585e50c6441aadf54ecb2c9f
- name: github.com/go-sql-driver/mysql
......@@ -34,7 +36,7 @@ imports:
- raster
- truetype
- name: github.com/golang/protobuf
version: e325f446bebc2998605911c0a2650d9920361d4a
version: 0a4f71a498b7c4812f64969510bcb4eca251e33a
subpackages:
- proto
- name: github.com/gorilla/context
......@@ -44,7 +46,7 @@ imports:
- name: github.com/gorilla/mux
version: bcd8bc72b08df0f70df986b97f95590779502d31
- name: github.com/gorilla/websocket
version: 3ab3a8b8831546bd18fd182c20687ca853b2bb13
version: ea4d1f681babbce9545c9c5f3d5194a789c89f5b
- name: github.com/hashicorp/errwrap
version: 7554cd9344cec97297fa6649b055a8c98c2a1e55
- name: github.com/hashicorp/go-msgpack
......@@ -52,9 +54,9 @@ imports:
subpackages:
- codec
- name: github.com/hashicorp/go-multierror
version: ed905158d87462226a13fe39ddf685ea65f1c11f
version: 83588e72410abfbe4df460eeb6f30841ae47d4c4
- name: github.com/hashicorp/go-sockaddr
version: 2d10d7c10258d11196c0ebf2943509e4afd06cd4
version: 41949a141473f6340abc6ba0fcd0f89da6f6f837
- name: github.com/hashicorp/golang-lru
version: 0a025b7e63adc15a622f29b0b2c4c3848243bbf6
subpackages:
......@@ -71,17 +73,17 @@ imports:
- json/scanner
- json/token
- name: github.com/hashicorp/memberlist
version: 16fe34d996eba2b68f6f46f26c51c617c6bc1bf0
version: 99594a4f171a77cb7cff01f143ccf608ac577c47
- name: github.com/inconshreveable/mousetrap
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
- name: github.com/jehiah/go-strftime
version: 834e15c05a45371503440cc195bbd05c9a0968d9
- name: github.com/lib/pq
version: 8837942c3e09574accbc5f150e2c5e057189cace
version: dd1fe2071026ce53f36a39112e645b4d4f5793a4
subpackages:
- oid
- name: github.com/magiconair/properties
version: 51463bfca2576e06c62a8504b5c0f06d61312647
version: be5ece7dd465ab0765a9682137865547526d1dfb
- name: github.com/mattermost/gorp
version: 995ddf2264c4ad45fbaf342f7500e4787ebae84a
- name: github.com/mattermost/rsc
......@@ -95,10 +97,13 @@ imports:
subpackages:
- pbutil
- name: github.com/miekg/dns
version: e78414ef75607394ad7d917824f07f381df2eafa
version: 0559e6d230af0a3a7273853cb6994ebea21bfbe5
- name: github.com/minio/go-homedir
version: 21304a94172ae3a09dee2cd86a12fb6f842138c7
- name: github.com/minio/minio-go
version: 2f03abaa07d8bc57faef16cda7655ea62a7e0bed
version: 5ca66c9a35ba1cd674484be99dc97aa0973afe12
subpackages:
- pkg/credentials
- pkg/encrypt
- pkg/policy
- pkg/s3signer
......@@ -116,13 +121,11 @@ imports:
- i18n/language
- i18n/translation
- name: github.com/NYTimes/gziphandler
version: 22d4470af89e09998fc16b35029df973932df4ae
version: 56545f4a5d46df9a6648819d1664c3a03a13ffdb
- name: github.com/pborman/uuid
version: a97ce2ca70fa5a848076093f05e639a89ca34d06
- name: github.com/pelletier/go-buffruneio
version: c37440a7cf42ac63b919c752ca73a85067e05992
version: e790cca94e6cc75c7064b1332e63811d4aae1a53
- name: github.com/pelletier/go-toml
version: fe7536c3dee2596cdd23ee9976a17c22bdaae286
version: 69d355db5304c0f7f809a2edc054553e7142f016
- name: github.com/pkg/errors
version: c605e284fe17294bda444b34710735b29d1a9d90
- name: github.com/prometheus/client_golang
......@@ -134,13 +137,13 @@ imports:
subpackages:
- go
- name: github.com/prometheus/common
version: 0d0c3d572886e0f2323ed376557f9eb99b97d25b
version: 3e6a7635bac6573d43f49f97b47eb9bda195dba8
subpackages:
- expfmt
- name: github.com/prometheus/procfs
version: 822d4a1f8edcbcbc71e8d1fd6527b12331a6d0ad
version: e645f4e5aaa8506fc71d6edbc5c4ff02c04c46f2
- name: github.com/rsc/letsencrypt
version: 76104d26167d38b6a0010f42bfc8ec5487742e8b
version: 33926faef6d434b854ea994228f11d0185faa0c1
- name: github.com/rwcarlsen/goexif
version: 709fab3d192d7c62f86043caff1e7e3fb0f42bd8
subpackages:
......@@ -159,7 +162,7 @@ imports:
- name: github.com/spf13/cast
version: acbeb36b902d72a7a4c18e8f3241075e7ab763e4
- name: github.com/spf13/cobra
version: 99b5d838ca16c25cc4944e323684f8415e8b10ba
version: 715f41bd7a70b5111f898b71ab484da52ee6266d
- name: github.com/spf13/jwalterweatherman
version: 0efa5202c04663c757d84f90f5219c1250baf94f
- name: github.com/spf13/pflag
......@@ -169,13 +172,13 @@ imports:
- name: github.com/tylerb/graceful
version: 4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb
- name: github.com/xenolf/lego
version: 28ead50ff1ca93acdb62734d3ed8da0206d036ff
version: 68261a8b20c034aae6b82c192e7bf4de75b17da8
subpackages:
- acme
- name: github.com/xtgo/uuid
version: a0b114877d4caeffbd7f87e3757c17fce570fea7
- name: golang.org/x/crypto
version: adbae1b6b6fb4b02448a0fc0dbbc9ba2b95b294d
version: 4d70248d17d12d1edb7153434a74001c1540938b
subpackages:
- bcrypt
- blowfish
......@@ -189,18 +192,18 @@ imports:
- tiff
- tiff/lzw
- name: golang.org/x/net
version: fe686d45ea04bc1bd4eff6a52865ce8757320325
version: 02ac38e2528ff4adea90f184d71a3faa04b4b1b0
subpackages:
- context
- html
- html/atom
- publicsuffix
- name: golang.org/x/sys
version: fb4cac33e3196ff7f507ab9b2d2a44b0142f5b5a
version: cd2c276457edda6df7fb04895d3fd6a6add42926
subpackages:
- unix
- name: golang.org/x/text
version: 4e9ab9ee170f2a39bd66c92b3e0a47ff47a4bc77
version: 836efe42bb4aa16aaa17b9c155d8813d336ed720
subpackages:
- transform
- unicode/norm
......@@ -215,8 +218,9 @@ imports:
- name: gopkg.in/gomail.v2
version: 81ebce5c23dfd25c6c67194b37d3dd3f338c98b1
- name: gopkg.in/olivere/elastic.v5
version: 3113f9b9ad37509fe5f8a0e5e91c96fdc4435e26
version: f5030c016b49a6fb0e1958bc765562246c0a912c
subpackages:
- config
- uritemplates
- name: gopkg.in/square/go-jose.v1
version: aa2e30fdd1fe9dd3394119af66451ae790d50e0d
......@@ -228,5 +232,5 @@ imports:
subpackages:
- store/memstore
- name: gopkg.in/yaml.v2
version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
version: 3b4ad1db5b2a649883ff3782f5f9f6fb52be71af
testImports: []
......@@ -5,7 +5,7 @@ import:
repo: https://github.com/mattermost/log4go.git
- package: github.com/dgryski/dgoogauth
- package: github.com/disintegration/imaging
version: v1.1.0
version: v1.2.0
- package: github.com/dyatlov/go-opengraph
subpackages:
- opengraph
......@@ -21,13 +21,13 @@ import:
- package: github.com/gorilla/mux
version: v1.4.0
- package: github.com/gorilla/websocket
version: v1.1.0
version: v1.2.0
- package: github.com/lib/pq
- package: github.com/mattermost/rsc
subpackages:
- qr
- package: github.com/minio/minio-go
version: v2.1.0
version: v3.0.0
- package: github.com/mssola/user_agent
version: v0.4.1
- package: github.com/nicksnyder/go-i18n
......@@ -35,8 +35,9 @@ import:
subpackages:
- i18n
- package: github.com/pborman/uuid
version: v1.0
version: v1.1
- package: github.com/rsc/letsencrypt
version: v0.0.1
- package: github.com/rwcarlsen/goexif
subpackages:
- exif
......@@ -80,6 +81,6 @@ import:
- package: github.com/prometheus/procfs
- package: github.com/cpanato/html2text
- package: gopkg.in/olivere/elastic.v5
version: v5.0.41
version: v5.0.43
- package: github.com/mattermost/gorp
version: 995ddf2264c4ad45fbaf342f7500e4787ebae84a
......@@ -97,6 +97,7 @@ func (w *GzipResponseWriter) Write(b []byte) (int, error) {
}
// Save the write into a buffer for later use in GZIP responseWriter (if content is long enough) or at close with regular responseWriter.
// On the first write, w.buf changes from nil to a valid slice
w.buf = append(w.buf, b...)
// If the global writes are bigger than the minSize, compression is enable.
......@@ -122,7 +123,9 @@ func (w *GzipResponseWriter) startGzip() error {
w.Header().Del(contentLength)
// Write the header to gzip response.
w.writeHeader()
if w.code != 0 {
w.ResponseWriter.WriteHeader(w.code)
}
// Initialize the GZIP response.
w.init()
......@@ -146,14 +149,6 @@ func (w *GzipResponseWriter) WriteHeader(code int) {
w.code = code
}
// writeHeader uses the saved code to send it to the ResponseWriter.
func (w *GzipResponseWriter) writeHeader() {
if w.code == 0 {
w.code = http.StatusOK
}
w.ResponseWriter.WriteHeader(w.code)
}
// init graps a new gzip writer from the gzipWriterPool and writes the correct
// content encoding header.
func (w *GzipResponseWriter) init() {
......@@ -166,19 +161,18 @@ func (w *GzipResponseWriter) init() {
// Close will close the gzip.Writer and will put it back in the gzipWriterPool.
func (w *GzipResponseWriter) Close() error {
// Buffer not nil means the regular response must be returned.
if w.buf != nil {
w.writeHeader()
// Make the write into the regular response.
_, writeErr := w.ResponseWriter.Write(w.buf)
// Returns the error if any at write.
if writeErr != nil {
return fmt.Errorf("gziphandler: write to regular responseWriter at close gets error: %q", writeErr.Error())
}
}
// If the GZIP responseWriter is not set no needs to close it.
if w.gw == nil {
// Gzip not trigged yet, write out regular response.
if w.code != 0 {
w.ResponseWriter.WriteHeader(w.code)
}
if w.buf != nil {
_, writeErr := w.ResponseWriter.Write(w.buf)
// Returns the error if any at write.
if writeErr != nil {
return fmt.Errorf("gziphandler: write to regular responseWriter at close gets error: %q", writeErr.Error())
}
}
return nil
}
......@@ -253,8 +247,6 @@ func NewGzipLevelAndMinSize(level, minSize int) (func(http.Handler) http.Handler
ResponseWriter: w,
index: index,
minSize: minSize,
buf: []byte{},
}
defer gw.Close()
......
......@@ -295,6 +295,30 @@ func TestStatusCodes(t *testing.T) {
}
}
func TestDontWriteWhenNotWrittenTo(t *testing.T) {
// When using gzip as middleware without ANY writes in the handler,
// ensure the gzip middleware doesn't touch the actual ResponseWriter
// either.
handler0 := GzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
}))
handler1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler0.ServeHTTP(w, r)
w.WriteHeader(404) // this only works if gzip didn't do a WriteHeader(200)
})
r := httptest.NewRequest("GET", "/", nil)
r.Header.Set("Accept-Encoding", "gzip")
w := httptest.NewRecorder()
handler1.ServeHTTP(w, r)
result := w.Result()
if result.StatusCode != 404 {
t.Errorf("StatusCode should have been 404 but was %d", result.StatusCode)
}
}
// --------------------------------------------------------------------
func BenchmarkGzipHandler_S2k(b *testing.B) { benchmark(b, false, 2048) }
......
......@@ -2,23 +2,25 @@ package imaging
import (
"image"
"image/color"
"math"
)
// Rotate90 rotates the image 90 degrees counterclockwise and returns the transformed image.
func Rotate90(img image.Image) *image.NRGBA {
// FlipH flips the image horizontally (from left to right) and returns the transformed image.
func FlipH(img image.Image) *image.NRGBA {
src := toNRGBA(img)
srcW := src.Bounds().Max.X
srcH := src.Bounds().Max.Y
dstW := srcH
dstH := srcW
dstW := srcW
dstH := srcH
dst := image.NewNRGBA(image.Rect(0, 0, dstW, dstH))
parallel(dstH, func(partStart, partEnd int) {
for dstY := partStart; dstY < partEnd; dstY++ {
for dstX := 0; dstX < dstW; dstX++ {
srcX := dstH - dstY - 1
srcY := dstX
srcX := dstW - dstX - 1
srcY := dstY
srcOff := srcY*src.Stride + srcX*4
dstOff := dstY*dst.Stride + dstX*4
......@@ -32,8 +34,8 @@ func Rotate90(img image.Image) *image.NRGBA {
return dst
}
// Rotate180 rotates the image 180 degrees counterclockwise and returns the transformed image.
func Rotate180(img image.Image) *image.NRGBA {
// FlipV flips the image vertically (from top to bottom) and returns the transformed image.
func FlipV(img image.Image) *image.NRGBA {