(out io.Writer, name string)
| 165 | } |
| 166 | |
| 167 | func (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 | |
| 201 | func shortDevice(s string) string { |
| 202 | if dev, err := protocol.DeviceIDFromString(s); err == nil && dev == protocol.LocalDeviceID { |
nothing calls this directly
no test coverage detected