Chris Lu 4 years ago
parent
commit
0da7ecfd29

+ 1 - 1
weed/filer/filer_conf_test.go

@@ -22,7 +22,7 @@ func TestFilerConf(t *testing.T) {
 		},
 		{
 			LocationPrefix: "/buckets/",
-			Replication: "001",
+			Replication:    "001",
 		},
 	}}
 	fc.doLoadConf(conf)

+ 20 - 20
weed/operation/needle_parse_test.go

@@ -76,29 +76,29 @@ func TestCreateNeedleFromRequest(t *testing.T) {
 	}
 
 	/*
-	{
-		mc.needleHandling = func(n *needle.Needle, originalSize int, err error) {
-			assert.Equal(t, nil, err, "upload: %v", err)
-			assert.Equal(t, "text/plain", string(n.Mime), "mime detection failed: %v", string(n.Mime))
-			assert.Equal(t, true, n.IsCompressed(), "this should be compressed")
-			assert.Equal(t, true, util.IsZstdContent(n.Data), "this should be zstd")
-			fmt.Printf("needle: %v, dataSize:%d originalSize:%d\n", n, len(n.Data), originalSize)
+		{
+			mc.needleHandling = func(n *needle.Needle, originalSize int, err error) {
+				assert.Equal(t, nil, err, "upload: %v", err)
+				assert.Equal(t, "text/plain", string(n.Mime), "mime detection failed: %v", string(n.Mime))
+				assert.Equal(t, true, n.IsCompressed(), "this should be compressed")
+				assert.Equal(t, true, util.IsZstdContent(n.Data), "this should be zstd")
+				fmt.Printf("needle: %v, dataSize:%d originalSize:%d\n", n, len(n.Data), originalSize)
+			}
+			zstdData, _ := util.ZstdData([]byte(textContent))
+			Upload("http://localhost:8080/389,0f084d17353afda0", "t.txt", false, bytes.NewReader(zstdData), true, "text/plain", nil, "")
 		}
-		zstdData, _ := util.ZstdData([]byte(textContent))
-		Upload("http://localhost:8080/389,0f084d17353afda0", "t.txt", false, bytes.NewReader(zstdData), true, "text/plain", nil, "")
-	}
 
-	{
-		mc.needleHandling = func(n *needle.Needle, originalSize int, err error) {
-			assert.Equal(t, nil, err, "upload: %v", err)
-			assert.Equal(t, "application/zstd", string(n.Mime), "mime detection failed: %v", string(n.Mime))
-			assert.Equal(t, false, n.IsCompressed(), "this should not be compressed")
-			assert.Equal(t, true, util.IsZstdContent(n.Data), "this should still be zstd")
-			fmt.Printf("needle: %v, dataSize:%d originalSize:%d\n", n, len(n.Data), originalSize)
+		{
+			mc.needleHandling = func(n *needle.Needle, originalSize int, err error) {
+				assert.Equal(t, nil, err, "upload: %v", err)
+				assert.Equal(t, "application/zstd", string(n.Mime), "mime detection failed: %v", string(n.Mime))
+				assert.Equal(t, false, n.IsCompressed(), "this should not be compressed")
+				assert.Equal(t, true, util.IsZstdContent(n.Data), "this should still be zstd")
+				fmt.Printf("needle: %v, dataSize:%d originalSize:%d\n", n, len(n.Data), originalSize)
+			}
+			zstdData, _ := util.ZstdData([]byte(textContent))
+			Upload("http://localhost:8080/389,0f084d17353afda0", "t.txt", false, bytes.NewReader(zstdData), false, "application/zstd", nil, "")
 		}
-		zstdData, _ := util.ZstdData([]byte(textContent))
-		Upload("http://localhost:8080/389,0f084d17353afda0", "t.txt", false, bytes.NewReader(zstdData), false, "application/zstd", nil, "")
-	}
 	*/
 
 }

+ 2 - 2
weed/server/volume_server_handlers_read.go

@@ -159,8 +159,8 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
 			if n.Data, err = util.DecompressData(n.Data); err != nil {
 				glog.V(0).Infoln("ungzip error:", err, r.URL.Path)
 			}
-		// } else if strings.Contains(r.Header.Get("Accept-Encoding"), "zstd") && util.IsZstdContent(n.Data) {
-		//	w.Header().Set("Content-Encoding", "zstd")
+			// } else if strings.Contains(r.Header.Get("Accept-Encoding"), "zstd") && util.IsZstdContent(n.Data) {
+			//	w.Header().Set("Content-Encoding", "zstd")
 		} else if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") && util.IsGzippedContent(n.Data) {
 			w.Header().Set("Content-Encoding", "gzip")
 		} else {

+ 1 - 1
weed/shell/command_fs_configure.go

@@ -107,7 +107,7 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
 			if err != nil {
 				return fmt.Errorf("parse replication %s: %v", *replication, err)
 			}
-			if *volumeGrowthCount % rp.GetCopyCount() != 0 {
+			if *volumeGrowthCount%rp.GetCopyCount() != 0 {
 				return fmt.Errorf("volumeGrowthCount %d should be devided by replication copy count %d", *volumeGrowthCount, rp.GetCopyCount())
 			}
 		}

+ 5 - 5
weed/storage/needle/needle_parse_upload.go

@@ -18,11 +18,11 @@ import (
 )
 
 type ParsedUpload struct {
-	FileName         string
-	Data             []byte
-	MimeType         string
-	PairMap          map[string]string
-	IsGzipped        bool
+	FileName  string
+	Data      []byte
+	MimeType  string
+	PairMap   map[string]string
+	IsGzipped bool
 	// IsZstd           bool
 	OriginalDataSize int
 	ModifiedTime     uint64

+ 3 - 4
weed/util/compression.go

@@ -55,15 +55,14 @@ func GzipData(input []byte) ([]byte, error) {
 	return buf.Bytes(), nil
 }
 
-
 func DecompressData(input []byte) ([]byte, error) {
 	if IsGzippedContent(input) {
 		return ungzipData(input)
 	}
 	/*
-	if IsZstdContent(input) {
-		return unzstdData(input)
-	}
+		if IsZstdContent(input) {
+			return unzstdData(input)
+		}
 	*/
 	return input, UnsupportedCompression
 }