MCPcopy
hub / github.com/syncthing/syncthing / loadParseIncludeFile

Function loadParseIncludeFile

lib/ignore/ignore.go:374–408  ·  view source on GitHub ↗
(filesystem fs.Filesystem, file string, cd ChangeDetector, linesSeen map[string]struct{})

Source from the content-addressed store, hash-verified

372}
373
374func loadParseIncludeFile(filesystem fs.Filesystem, file string, cd ChangeDetector, linesSeen map[string]struct{}) ([]Pattern, error) {
375 // Allow escaping the folders filesystem.
376 // TODO: Deprecate, somehow?
377 if filesystem.Type() == fs.FilesystemTypeBasic {
378 uri := filesystem.URI()
379 joined := filepath.Join(uri, file)
380 if !fs.IsParent(joined, uri) {
381 filesystem = fs.NewFilesystem(filesystem.Type(), filepath.Dir(joined))
382 file = filepath.Base(joined)
383 }
384 }
385
386 if cd.Seen(filesystem, file) {
387 return nil, errors.New("multiple include")
388 }
389
390 fd, info, err := loadIgnoreFile(filesystem, file)
391 if err != nil {
392 // isNotExist is considered "ok" in a sense of that a folder doesn't have to act
393 // upon it. This is because it is allowed for .stignore to not exist. However,
394 // included ignore files are not allowed to be missing and these errors should be
395 // acted upon on. So we don't preserve the error chain here and manually set an
396 // error instead, if the file is missing.
397 if fs.IsNotExist(err) {
398 err = errors.New("file not found")
399 }
400 return nil, err
401 }
402 defer fd.Close()
403
404 cd.Remember(filesystem, file, info.ModTime())
405
406 _, patterns, err := parseIgnoreFile(filesystem, fd, file, cd, linesSeen)
407 return patterns, err
408}
409
410func parseLine(line string) ([]Pattern, error) {
411 // We use native normalization internally, thus the patterns must match

Callers 1

parseIgnoreFileFunction · 0.85

Calls 12

IsParentFunction · 0.92
NewFilesystemFunction · 0.92
IsNotExistFunction · 0.92
loadIgnoreFileFunction · 0.85
parseIgnoreFileFunction · 0.85
TypeMethod · 0.65
URIMethod · 0.65
SeenMethod · 0.65
NewMethod · 0.65
CloseMethod · 0.65
RememberMethod · 0.65
ModTimeMethod · 0.65

Tested by

no test coverage detected