MCPcopy
hub / github.com/syncthing/syncthing / LoadIgnores

Method LoadIgnores

lib/model/model.go:2174–2204  ·  view source on GitHub ↗

LoadIgnores loads or refreshes the ignore patterns from disk, if the folder is healthy, and returns the refreshed lines and patterns.

(folder string)

Source from the content-addressed store, hash-verified

2172// LoadIgnores loads or refreshes the ignore patterns from disk, if the
2173// folder is healthy, and returns the refreshed lines and patterns.
2174func (m *model) LoadIgnores(folder string) ([]string, []string, error) {
2175 m.mut.RLock()
2176 cfg, cfgOk := m.folderCfgs[folder]
2177 ignores, ignoresOk := m.folderIgnores[folder]
2178 m.mut.RUnlock()
2179
2180 if !cfgOk {
2181 cfg, cfgOk = m.cfg.Folder(folder)
2182 if !cfgOk {
2183 return nil, nil, fmt.Errorf("folder %s does not exist", folder)
2184 }
2185 }
2186
2187 if cfg.Type == config.FolderTypeReceiveEncrypted {
2188 return nil, nil, nil
2189 }
2190
2191 if !ignoresOk {
2192 ignores = ignore.New(cfg.Filesystem())
2193 }
2194
2195 err := ignores.Load(".stignore")
2196 if fs.IsNotExist(err) {
2197 // Having no ignores is not an error.
2198 return nil, nil, nil
2199 }
2200
2201 // Return lines and patterns, which may have some meaning even when err
2202 // != nil, depending on the specific error.
2203 return ignores.Lines(), ignores.Patterns(), err
2204}
2205
2206// CurrentIgnores returns the currently loaded set of ignore patterns,
2207// whichever it may be. No attempt is made to load or refresh ignore

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
IsNotExistFunction · 0.92
FilesystemMethod · 0.80
LinesMethod · 0.80
PatternsMethod · 0.80
FolderMethod · 0.65
LoadMethod · 0.45

Tested by

no test coverage detected