cmd/stindex: Add dumping folder meta

This commit is contained in:
Jakob Borg
2020-09-04 11:39:21 +02:00
parent b7986801cd
commit 71bfad0bc6
4 changed files with 91 additions and 57 deletions
+28
View File
@@ -12,6 +12,7 @@ package db
import (
"bytes"
"fmt"
"strings"
"time"
"github.com/syncthing/syncthing/lib/protocol"
@@ -186,6 +187,33 @@ func (c Counts) TotalItems() int32 {
return c.Files + c.Directories + c.Symlinks + c.Deleted
}
func (c Counts) String() string {
dev, _ := protocol.DeviceIDFromBytes(c.DeviceID)
var flags strings.Builder
if c.LocalFlags&needFlag != 0 {
flags.WriteString("Need")
}
if c.LocalFlags&protocol.FlagLocalIgnored != 0 {
flags.WriteString("Ignored")
}
if c.LocalFlags&protocol.FlagLocalMustRescan != 0 {
flags.WriteString("Rescan")
}
if c.LocalFlags&protocol.FlagLocalReceiveOnly != 0 {
flags.WriteString("Recvonly")
}
if c.LocalFlags&protocol.FlagLocalUnsupported != 0 {
flags.WriteString("Unsupported")
}
if c.LocalFlags != 0 {
flags.WriteString(fmt.Sprintf("(%x)", c.LocalFlags))
}
if flags.Len() == 0 {
flags.WriteString("---")
}
return fmt.Sprintf("{Device:%v, Files:%d, Dirs:%d, Symlinks:%d, Del:%d, Bytes:%d, Seq:%d, Flags:%s}", dev, c.Files, c.Directories, c.Symlinks, c.Deleted, c.Bytes, c.Sequence, flags.String())
}
// Equal compares the numbers only, not sequence/dev/flags.
func (c Counts) Equal(o Counts) bool {
return c.Files == o.Files && c.Directories == o.Directories && c.Symlinks == o.Symlinks && c.Deleted == o.Deleted && c.Bytes == o.Bytes