| 24 | ) |
| 25 | |
| 26 | func (s *folderDB) GetDeviceFile(device protocol.DeviceID, file string) (protocol.FileInfo, bool, error) { |
| 27 | file = osutil.NormalizedFilename(file) |
| 28 | |
| 29 | var ind indirectFI |
| 30 | err := s.stmt(` |
| 31 | SELECT fi.fiprotobuf, bl.blprotobuf FROM fileinfos fi |
| 32 | INNER JOIN files f on fi.sequence = f.sequence |
| 33 | LEFT JOIN blocklists bl ON bl.blocklist_hash = f.blocklist_hash |
| 34 | INNER JOIN devices d ON f.device_idx = d.idx |
| 35 | INNER JOIN file_names n ON f.name_idx = n.idx |
| 36 | WHERE d.device_id = ? AND n.name = ? |
| 37 | `).Get(&ind, device.String(), file) |
| 38 | if errors.Is(err, sql.ErrNoRows) { |
| 39 | return protocol.FileInfo{}, false, nil |
| 40 | } |
| 41 | if err != nil { |
| 42 | return protocol.FileInfo{}, false, wrap(err) |
| 43 | } |
| 44 | fi, err := ind.FileInfo() |
| 45 | if err != nil { |
| 46 | return protocol.FileInfo{}, false, wrap(err, "indirect") |
| 47 | } |
| 48 | return fi, true, nil |
| 49 | } |
| 50 | |
| 51 | func (s *folderDB) AllLocalFiles(device protocol.DeviceID) (iter.Seq[protocol.FileInfo], func() error) { |
| 52 | it, errFn := iterStructs[indirectFI](s.stmt(` |