aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-12-22 13:58:16 -0800
committerChris Lu <chris.lu@gmail.com>2018-12-22 13:58:16 -0800
commit852ee21835682d1b6ce52b766989a8ff82ebbf80 (patch)
tree0fadc3b70ea01c7fd6c14a8dfaf7fde34d097d07
parentbe946c9e54db3297a68715d1789598d004b71e60 (diff)
downloadseaweedfs-852ee21835682d1b6ce52b766989a8ff82ebbf80.tar.xz
seaweedfs-852ee21835682d1b6ce52b766989a8ff82ebbf80.zip
avoid .gz auto decompression
-rw-r--r--weed/command/filer_copy.go8
-rw-r--r--weed/operation/submit.go6
-rw-r--r--weed/storage/needle_parse_multipart.go12
3 files changed, 6 insertions, 20 deletions
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go
index b519afe86..0f4f96f1b 100644
--- a/weed/command/filer_copy.go
+++ b/weed/command/filer_copy.go
@@ -15,7 +15,6 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
"io"
"net/http"
- "path"
"strconv"
"time"
)
@@ -165,7 +164,6 @@ func uploadFileAsOne(filerAddress, filerGrpcAddress string, urlFolder string, f
// upload the file content
fileName := filepath.Base(f.Name())
mimeType := detectMimeType(f)
- isGzipped := isGzipped(fileName)
var chunks []*filer_pb.FileChunk
@@ -184,7 +182,7 @@ func uploadFileAsOne(filerAddress, filerGrpcAddress string, urlFolder string, f
targetUrl := "http://" + assignResult.Url + "/" + assignResult.Fid
- uploadResult, err := operation.Upload(targetUrl, fileName, f, isGzipped, mimeType, nil, "")
+ uploadResult, err := operation.Upload(targetUrl, fileName, f, false, mimeType, nil, "")
if err != nil {
fmt.Printf("upload data %v to %s: %v\n", fileName, targetUrl, err)
return false
@@ -318,10 +316,6 @@ func uploadFileInChunks(filerAddress, filerGrpcAddress string, urlFolder string,
return true
}
-func isGzipped(filename string) bool {
- return strings.ToLower(path.Ext(filename)) == ".gz"
-}
-
func detectMimeType(f *os.File) string {
head := make([]byte, 512)
f.Seek(0, 0)
diff --git a/weed/operation/submit.go b/weed/operation/submit.go
index b81f64593..63ab694a7 100644
--- a/weed/operation/submit.go
+++ b/weed/operation/submit.go
@@ -18,7 +18,6 @@ type FilePart struct {
Reader io.Reader
FileName string
FileSize int64
- IsGzipped bool
MimeType string
ModTime int64 //in seconds
Replication string
@@ -103,7 +102,6 @@ func newFilePart(fullPathFilename string) (ret FilePart, err error) {
ret.ModTime = fi.ModTime().UTC().Unix()
ret.FileSize = fi.Size()
ext := strings.ToLower(path.Ext(fullPathFilename))
- ret.IsGzipped = ext == ".gz"
ret.FileName = fi.Name()
if ext != "" {
ret.MimeType = mime.TypeByExtension(ext)
@@ -193,7 +191,7 @@ func (fi FilePart) Upload(maxMB int, master string, secret security.Secret) (ret
cm.DeleteChunks(master)
}
} else {
- ret, e := Upload(fileUrl, baseName, fi.Reader, fi.IsGzipped, fi.MimeType, nil, jwt)
+ ret, e := Upload(fileUrl, baseName, fi.Reader, false, fi.MimeType, nil, jwt)
if e != nil {
return 0, e
}
@@ -203,7 +201,7 @@ func (fi FilePart) Upload(maxMB int, master string, secret security.Secret) (ret
}
func upload_one_chunk(filename string, reader io.Reader, master,
- fileUrl string, jwt security.EncodedJwt,
+fileUrl string, jwt security.EncodedJwt,
) (size uint32, e error) {
glog.V(4).Info("Uploading part ", filename, " to ", fileUrl, "...")
uploadResult, uploadError := Upload(fileUrl, filename, reader, false,
diff --git a/weed/storage/needle_parse_multipart.go b/weed/storage/needle_parse_multipart.go
index 8d5b96a27..2ebf86d96 100644
--- a/weed/storage/needle_parse_multipart.go
+++ b/weed/storage/needle_parse_multipart.go
@@ -83,6 +83,9 @@ func parseMultipart(r *http.Request) (
}
if part.Header.Get("Content-Encoding") == "gzip" {
+ if unzipped, e := operation.UnGzipData(data); e == nil {
+ originalDataSize = len(unzipped)
+ }
isGzipped = true
} else if operation.IsGzippable(ext, mtype) {
if data, e = operation.GzipData(data); e != nil {
@@ -90,15 +93,6 @@ func parseMultipart(r *http.Request) (
}
isGzipped = true
}
- if ext == ".gz" {
- if strings.HasSuffix(fileName, ".css.gz") ||
- strings.HasSuffix(fileName, ".html.gz") ||
- strings.HasSuffix(fileName, ".txt.gz") ||
- strings.HasSuffix(fileName, ".js.gz") {
- fileName = fileName[:len(fileName)-3]
- isGzipped = true
- }
- }
}
return