MCPcopy Index your code
hub / github.com/syncthing/syncthing / DebugFilePattern

Method DebugFilePattern

internal/db/sqlite/folderdb_local.go:167–199  ·  view source on GitHub ↗
(out io.Writer, name string)

Source from the content-addressed store, hash-verified

165}
166
167func (s *folderDB) DebugFilePattern(out io.Writer, name string) error {
168 type hashFileMetadata struct {
169 db.FileMetadata
170
171 Version dbVector
172 BlocklistHash []byte
173 DeviceID string
174 }
175 name = "%" + name + "%"
176 res := itererr.Zip(iterStructs[hashFileMetadata](s.stmt(`
177 SELECT f.sequence, n.name, f.type, f.modified as modnanos, f.size, f.deleted, f.local_flags as localflags, v.version, f.blocklist_hash as blocklisthash, d.device_id as deviceid FROM files f
178 INNER JOIN devices d ON d.idx = f.device_idx
179 INNER JOIN file_names n ON n.idx = f.name_idx
180 INNER JOIN file_versions v ON v.idx = f.version_idx
181 WHERE n.name LIKE ?
182 ORDER BY n.name, f.device_idx
183 `).Queryx(name)))
184
185 delMap := map[bool]string{
186 true: "del",
187 false: "---",
188 }
189
190 tw := tabwriter.NewWriter(out, 2, 2, 2, ' ', 0)
191 fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "DEVICE", "TYPE", "NAME", "SEQUENCE", "DELETED", "MODIFIED", "SIZE", "FLAGS", "VERSION", "BLOCKLIST")
192 for row, err := range res {
193 if err != nil {
194 return err
195 }
196 fmt.Fprintf(tw, "%s\t%s\t%s\t%d\t%s\t%s\t%d\t%s\t%s\t%s\n", shortDevice(row.DeviceID), shortType(row.Type), row.Name, row.Sequence, delMap[row.Deleted], row.ModTime().UTC().Format(time.RFC3339Nano), row.Size, row.LocalFlags.HumanString(), row.Version.HumanString(), shortHash(row.BlocklistHash))
197 }
198 return tw.Flush()
199}
200
201func shortDevice(s string) string {
202 if dev, err := protocol.DeviceIDFromString(s); err == nil && dev == protocol.LocalDeviceID {

Callers

nothing calls this directly

Calls 9

ZipFunction · 0.92
shortDeviceFunction · 0.85
shortTypeFunction · 0.85
shortHashFunction · 0.85
stmtMethod · 0.80
QueryxMethod · 0.65
ModTimeMethod · 0.65
HumanStringMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected