in code/go/internal/linkedfiles/linkedfiles.go [34:59]
func NewLinkedFile(linkFilePath string) (Link, error) {
var l Link
firstLine, err := readFirstLine(linkFilePath)
if err != nil {
return Link{}, err
}
l.LinkFilePath = linkFilePath
fields := strings.Fields(firstLine)
l.IncludedFilePath = fields[0]
if len(fields) == 2 {
l.LinkChecksum = fields[1]
}
pathName := filepath.Join(filepath.Dir(linkFilePath), filepath.FromSlash(l.IncludedFilePath))
cs, err := getLinkedFileChecksum(pathName)
if err != nil {
return Link{}, fmt.Errorf("could not collect file %v: %w", l.IncludedFilePath, err)
}
if l.LinkChecksum == cs {
l.UpToDate = true
}
l.IncludedFileContentsChecksum = cs
return l, nil
}