repochecker/*-inspector: Refactor file opening

This commit is contained in:
nemunaire 2022-11-21 19:02:37 +01:00
parent 257c594dbe
commit 14f10c91db
4 changed files with 31 additions and 31 deletions

View file

@ -110,20 +110,12 @@ func CheckTextFile(fd *os.File) (errs []error) {
}
func InspectFileForIPAddr(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
i, ok := sync.GlobalImporter.(sync.LocalImporter)
if !ok {
log.Printf("Unable to load `pcap-inspector.so` as the current Importer is not a LocalImporter (%T).", sync.GlobalImporter)
return
}
path := i.GetLocalPath(file.GetOrigin())
fd, err := os.Open(path)
fd, closer, err := sync.GetFile(sync.GlobalImporter, file.GetOrigin())
if err != nil {
log.Printf("Unable to open %q: %s", path, err.Error())
log.Printf("Unable to open %q: %s", file.GetOrigin(), err.Error())
return
}
defer fd.Close()
defer closer()
switch filepath.Ext(file.Name) {
case ".pcap":