aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-08-23 00:00:36 -0700
committerChris Lu <chris.lu@gmail.com>2020-08-23 00:00:36 -0700
commitd60bcbf08ab11c75ffcba93be586ef9e42ccdc40 (patch)
tree8debec4268d01dccbe96ac44533d74b074c62775
parent5e6b714836a365852378c117e48d6228ce925538 (diff)
downloadseaweedfs-d60bcbf08ab11c75ffcba93be586ef9e42ccdc40.tar.xz
seaweedfs-d60bcbf08ab11c75ffcba93be586ef9e42ccdc40.zip
sorting chunks
-rw-r--r--weed/filer2/filechunks.go2
-rw-r--r--weed/filesys/file.go2
-rw-r--r--weed/shell/command_fs_meta_cat.go8
3 files changed, 10 insertions, 2 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go
index 1ab6679f9..9ab7ea355 100644
--- a/weed/filer2/filechunks.go
+++ b/weed/filer2/filechunks.go
@@ -219,7 +219,7 @@ func NonOverlappingVisibleIntervals(lookupFileIdFn LookupFileIdFunctionType, chu
chunks, _, err = ResolveChunkManifest(lookupFileIdFn, chunks)
sort.Slice(chunks, func(i, j int) bool {
- return chunks[i].Mtime < chunks[j].Mtime
+ return chunks[i].Fid.FileKey < chunks[j].Fid.FileKey
})
var newVisibles []VisibleInterval
diff --git a/weed/filesys/file.go b/weed/filesys/file.go
index d57f6cc57..d9e1f2662 100644
--- a/weed/filesys/file.go
+++ b/weed/filesys/file.go
@@ -258,7 +258,7 @@ func (file *File) maybeLoadEntry(ctx context.Context) error {
func (file *File) addChunks(chunks []*filer_pb.FileChunk) {
sort.Slice(chunks, func(i, j int) bool {
- return chunks[i].Mtime < chunks[j].Mtime
+ return chunks[i].Fid.FileKey < chunks[j].Fid.FileKey
})
var newVisibles []filer2.VisibleInterval
diff --git a/weed/shell/command_fs_meta_cat.go b/weed/shell/command_fs_meta_cat.go
index 0679ec075..8cba2d520 100644
--- a/weed/shell/command_fs_meta_cat.go
+++ b/weed/shell/command_fs_meta_cat.go
@@ -3,6 +3,7 @@ package shell
import (
"fmt"
"io"
+ "sort"
"github.com/golang/protobuf/jsonpb"
@@ -54,6 +55,13 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.W
Indent: " ",
}
+ sort.Slice(respLookupEntry.Entry.Chunks, func(i, j int) bool {
+ if respLookupEntry.Entry.Chunks[i].Offset == respLookupEntry.Entry.Chunks[j].Offset {
+ return respLookupEntry.Entry.Chunks[i].Mtime < respLookupEntry.Entry.Chunks[j].Mtime
+ }
+ return respLookupEntry.Entry.Chunks[i].Offset < respLookupEntry.Entry.Chunks[j].Offset
+ })
+
text, marshalErr := m.MarshalToString(respLookupEntry.Entry)
if marshalErr != nil {
return fmt.Errorf("marshal meta: %v", marshalErr)