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

Method Load

lib/ignore/ignore.go:174–198  ·  view source on GitHub ↗

Load and parse a file. The returned error may be of type *ParseError in which case a file was loaded from disk but the patterns could not be parsed. In this case the contents of the file are nonetheless available in the Lines() method.

(file string)

Source from the content-addressed store, hash-verified

172// parsed. In this case the contents of the file are nonetheless available
173// in the Lines() method.
174func (m *Matcher) Load(file string) error {
175 m.mut.Lock()
176 defer m.mut.Unlock()
177
178 if m.changeDetector.Seen(m.fs, file) && !m.changeDetector.Changed() {
179 return nil
180 }
181
182 fd, info, err := loadIgnoreFile(m.fs, file)
183 if err != nil {
184 m.parseLocked(&bytes.Buffer{}, file)
185 return err
186 }
187 defer fd.Close()
188
189 m.changeDetector.Reset()
190
191 err = m.parseLocked(fd, file)
192 // If we failed to parse, don't cache, as next time Load is called
193 // we'll pretend it's all good.
194 if err == nil {
195 m.changeDetector.Remember(m.fs, file, info.ModTime())
196 }
197 return err
198}
199
200// Load and parse an io.Reader. See Load() for notes on the returned error.
201func (m *Matcher) Parse(r io.Reader, file string) error {

Callers 15

TestStressBufferPoolFunction · 0.45
TotMethod · 0.45
LastMethod · 0.45
TotMethod · 0.45
LastMethod · 0.45
TotalInOutFunction · 0.45
NATTypeMethod · 0.45
unlimitedMethod · 0.45
ReadFromMethod · 0.45
LoadIgnoresMethod · 0.45

Calls 9

parseLockedMethod · 0.95
loadIgnoreFileFunction · 0.85
UnlockMethod · 0.80
SeenMethod · 0.65
ChangedMethod · 0.65
CloseMethod · 0.65
ResetMethod · 0.65
RememberMethod · 0.65
ModTimeMethod · 0.65

Tested by 11

TestStressBufferPoolFunction · 0.36
TestFolderRestartZombiesFunction · 0.36
TestIgnoreFunction · 0.36
TestCachingFunction · 0.36
BenchmarkMatchCachedFunction · 0.36
TestCacheReloadFunction · 0.36
TestHashFunction · 0.36
TestHashOfEmptyFunction · 0.36
TestIssue4901Function · 0.36
TestWalkSubFunction · 0.36
TestWalkFunction · 0.36