diff options
| author | tnextday <fw2k4@163.com> | 2015-12-02 21:27:29 +0800 |
|---|---|---|
| committer | tnextday <fw2k4@163.com> | 2015-12-02 21:27:29 +0800 |
| commit | 662915e6915d18a9e45b73577f93ef3be6562f4e (patch) | |
| tree | ef44a0237091e1bc2d395679372b87e682ebbb96 /go/operation/chunked_file.go | |
| parent | 520875d45504f0b659de7f4ff656634489100416 (diff) | |
| download | seaweedfs-662915e6915d18a9e45b73577f93ef3be6562f4e.tar.xz seaweedfs-662915e6915d18a9e45b73577f93ef3be6562f4e.zip | |
Delete all chunks when delete a ChunkManifest
LoadChunkManifest can uncompress buffer
move compress.go from storage to operation because of import cycle
MakeFile add cross complete command
Diffstat (limited to 'go/operation/chunked_file.go')
| -rw-r--r-- | go/operation/chunked_file.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/go/operation/chunked_file.go b/go/operation/chunked_file.go index 0e455e93a..33cb25703 100644 --- a/go/operation/chunked_file.go +++ b/go/operation/chunked_file.go @@ -30,10 +30,10 @@ type ChunkInfo struct { type ChunkList []*ChunkInfo type ChunkManifest struct { - Name string `json:"name,omitempty"` - Mime string `json:"mime,omitempty"` - Size int64 `json:"size,omitempty"` - Chunks ChunkList `json:"chunks,omitempty"` + Name string `json:"name,omitempty"` + Mime string `json:"mime,omitempty"` + Size int64 `json:"size,omitempty"` + Chunks ChunkList `json:"chunks,omitempty"` } // seekable chunked file reader @@ -50,7 +50,13 @@ func (s ChunkList) Len() int { return len(s) } func (s ChunkList) Less(i, j int) bool { return s[i].Offset < s[j].Offset } func (s ChunkList) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func LoadChunkedManifest(buffer []byte) (*ChunkManifest, error) { +func LoadChunkManifest(buffer []byte, isGzipped bool) (*ChunkManifest, error) { + if isGzipped { + var err error + if buffer, err = UnGzipData(buffer); err != nil { + return nil, err + } + } cm := ChunkManifest{} if e := json.Unmarshal(buffer, &cm); e != nil { return nil, e |
