MCPcopy
hub / github.com/syncthing/syncthing / Load

Function Load

lib/config/wrapper.go:163–176  ·  view source on GitHub ↗

Load loads an existing file on disk and returns a new configuration wrapper. The returned Wrapper is a suture.Service, thus needs to be started (added to a supervisor).

(path string, myID protocol.DeviceID, evLogger events.Logger)

Source from the content-addressed store, hash-verified

161// The returned Wrapper is a suture.Service, thus needs to be started (added to
162// a supervisor).
163func Load(path string, myID protocol.DeviceID, evLogger events.Logger) (Wrapper, int, error) {
164 fd, err := os.Open(path)
165 if err != nil {
166 return nil, 0, err
167 }
168 defer fd.Close()
169
170 cfg, originalVersion, err := ReadXML(fd, myID)
171 if err != nil {
172 return nil, 0, err
173 }
174
175 return Wrap(path, cfg, myID, evLogger), originalVersion, nil
176}
177
178func (w *wrapper) ConfigPath() string {
179 return w.path

Callers 13

LoadConfigAtStartupFunction · 0.92
eventLoopMethod · 0.92
TestSymlinksFunction · 0.92
TestFileTypeChangeFunction · 0.92
TestOverrideFunction · 0.92
loadOrDefaultConfigFunction · 0.92
loadGUIConfigFunction · 0.92
GenerateFunction · 0.92

Calls 4

ReadXMLFunction · 0.85
WrapFunction · 0.85
OpenMethod · 0.65
CloseMethod · 0.65

Tested by 8

TestSymlinksFunction · 0.74
TestFileTypeChangeFunction · 0.74
TestOverrideFunction · 0.74
loadFunction · 0.68