mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
weed export: print out [start,stop) content range
This commit is contained in:
parent
b5add9b8f9
commit
103fafe00b
|
@ -70,13 +70,13 @@ var (
|
|||
localLocation, _ = time.LoadLocation("Local")
|
||||
)
|
||||
|
||||
func printNeedle(vid needle.VolumeId, n *needle.Needle, version needle.Version, deleted bool) {
|
||||
func printNeedle(vid needle.VolumeId, n *needle.Needle, version needle.Version, deleted bool, offset int64, onDiskSize int64) {
|
||||
key := needle.NewFileIdFromNeedle(vid, n).String()
|
||||
size := int32(n.DataSize)
|
||||
if version == needle.Version1 {
|
||||
size = int32(n.Size)
|
||||
}
|
||||
fmt.Printf("%s\t%s\t%d\t%t\t%s\t%s\t%s\t%t\n",
|
||||
fmt.Printf("%s\t%s\t%d\t%t\t%s\t%s\t%s\t%t\t%d\t%d\n",
|
||||
key,
|
||||
n.Name,
|
||||
size,
|
||||
|
@ -85,6 +85,8 @@ func printNeedle(vid needle.VolumeId, n *needle.Needle, version needle.Version,
|
|||
n.LastModifiedString(),
|
||||
n.Ttl.String(),
|
||||
deleted,
|
||||
offset,
|
||||
offset+onDiskSize,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -124,17 +126,17 @@ func (scanner *VolumeFileScanner4Export) VisitNeedle(n *needle.Needle, offset in
|
|||
if tarOutputFile != nil {
|
||||
return writeFile(vid, n)
|
||||
} else {
|
||||
printNeedle(vid, n, scanner.version, false)
|
||||
printNeedle(vid, n, scanner.version, false, offset, n.DiskSize(scanner.version))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
if *showDeleted && tarOutputFile == nil {
|
||||
if n.DataSize > 0 {
|
||||
printNeedle(vid, n, scanner.version, true)
|
||||
printNeedle(vid, n, scanner.version, true, offset, n.DiskSize(scanner.version))
|
||||
} else {
|
||||
n.Name = []byte("*tombstone")
|
||||
printNeedle(vid, n, scanner.version, true)
|
||||
printNeedle(vid, n, scanner.version, true, offset, n.DiskSize(scanner.version))
|
||||
}
|
||||
}
|
||||
glog.V(2).Infof("This seems deleted %d size %d", n.Id, n.Size)
|
||||
|
@ -208,7 +210,7 @@ func runExport(cmd *Command, args []string) bool {
|
|||
}
|
||||
|
||||
if tarOutputFile == nil {
|
||||
fmt.Printf("key\tname\tsize\tgzip\tmime\tmodified\tttl\tdeleted\n")
|
||||
fmt.Printf("key\tname\tsize\tgzip\tmime\tmodified\tttl\tdeleted\tstart\tstop\n")
|
||||
}
|
||||
|
||||
err = storage.ScanVolumeFile(util.ResolvePath(*export.dir), *export.collection, vid, storage.NeedleMapInMemory, volumeFileScanner)
|
||||
|
|
|
@ -66,7 +66,7 @@ func formatNeedleIdCookie(key NeedleId, cookie Cookie) string {
|
|||
NeedleIdToBytes(bytes[0:NeedleIdSize], key)
|
||||
CookieToBytes(bytes[NeedleIdSize:NeedleIdSize+CookieSize], cookie)
|
||||
nonzero_index := 0
|
||||
for ; bytes[nonzero_index] == 0; nonzero_index++ {
|
||||
for ; bytes[nonzero_index] == 0 && nonzero_index < NeedleIdSize; nonzero_index++ {
|
||||
}
|
||||
return hex.EncodeToString(bytes[nonzero_index:])
|
||||
}
|
||||
|
|
|
@ -381,10 +381,8 @@ func ScanVolumeFile(dirname string, collection string, id needle.VolumeId,
|
|||
if v, err = loadVolumeWithoutIndex(dirname, collection, id, needleMapKind); err != nil {
|
||||
return fmt.Errorf("failed to load volume %d: %v", id, err)
|
||||
}
|
||||
if v.volumeInfo.Version == 0 {
|
||||
if err = volumeFileScanner.VisitSuperBlock(v.SuperBlock); err != nil {
|
||||
return fmt.Errorf("failed to process volume %d super block: %v", id, err)
|
||||
}
|
||||
if err = volumeFileScanner.VisitSuperBlock(v.SuperBlock); err != nil {
|
||||
return fmt.Errorf("failed to process volume %d super block: %v", id, err)
|
||||
}
|
||||
defer v.Close()
|
||||
|
||||
|
@ -406,8 +404,9 @@ func ScanVolumeFileFrom(version needle.Version, datBackend backend.BackendStorag
|
|||
for n != nil {
|
||||
var needleBody []byte
|
||||
if volumeFileScanner.ReadNeedleBody() {
|
||||
// println("needle", n.Id.String(), "offset", offset, "size", n.Size, "rest", rest)
|
||||
if needleBody, err = n.ReadNeedleBody(datBackend, version, offset+NeedleHeaderSize, rest); err != nil {
|
||||
glog.V(0).Infof("cannot read needle body: %v", err)
|
||||
glog.V(0).Infof("cannot read needle head [%d, %d) body [%d, %d) body length %d: %v", offset, offset+NeedleHeaderSize, offset+NeedleHeaderSize, offset+NeedleHeaderSize+rest, rest, err)
|
||||
// err = fmt.Errorf("cannot read needle body: %v", err)
|
||||
// return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue