func New(opts ...config.Option) (core.Identifier, error) { for _, v := range opts { v() } pronom, err := NewPronom() if err != nil { return nil, err } return &Identifier{ infos: infos(pronom.Infos()), Base: identifier.New(pronom, config.ZipPuid()), }, nil }
func (r *Recorder) Record(m core.MatcherType, res core.Result) bool { switch m { default: return false case core.NameMatcher: if hit, id := r.Hit(m, res.Index()); hit { r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), extScore) return true } else { return false } case core.MIMEMatcher: if hit, id := r.Hit(m, res.Index()); hit { r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), mimeScore) return true } else { return false } case core.ContainerMatcher: // add zip default if res.Index() < 0 { if r.ZipDefault() { r.cscore += incScore r.ids = add(r.ids, r.Name(), config.ZipPuid(), r.infos[config.ZipPuid()], res.Basis(), r.cscore) } return false } if hit, id := r.Hit(m, res.Index()); hit { r.cscore += incScore basis := res.Basis() p, t := r.Place(core.ContainerMatcher, res.Index()) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.Name(), id, r.infos[id], basis, r.cscore) return true } else { return false } case core.ByteMatcher: if hit, id := r.Hit(m, res.Index()); hit { if r.satisfied { return true } r.cscore += incScore basis := res.Basis() p, t := r.Place(core.ByteMatcher, res.Index()) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.Name(), id, r.infos[id], basis, r.cscore) return true } else { return false } case core.TextMatcher: if hit, id := r.Hit(m, res.Index()); hit { if r.satisfied { return true } r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), textScore) return true } else { return false } } }