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

Method GetDeviceFile

internal/db/sqlite/folderdb_local.go:26–49  ·  view source on GitHub ↗
(device protocol.DeviceID, file string)

Source from the content-addressed store, hash-verified

24)
25
26func (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
51func (s *folderDB) AllLocalFiles(device protocol.DeviceID) (iter.Seq[protocol.FileInfo], func() error) {
52 it, errFn := iterStructs[indirectFI](s.stmt(`

Callers

nothing calls this directly

Calls 7

FileInfoMethod · 0.95
NormalizedFilenameFunction · 0.92
stmtMethod · 0.80
wrapFunction · 0.70
GetMethod · 0.65
StringMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected