repochecker/*-inspector: Refactor file opening
This commit is contained in:
parent
257c594dbe
commit
14f10c91db
4 changed files with 31 additions and 31 deletions
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
@ -10,20 +9,12 @@ import (
|
|||
)
|
||||
|
||||
func InspectFile(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
i, ok := sync.GlobalImporter.(sync.LocalImporter)
|
||||
if !ok {
|
||||
log.Printf("Unable to load `file-inspector.so` as the current Importer is not a LocalImporter (%T).", sync.GlobalImporter)
|
||||
return
|
||||
}
|
||||
|
||||
path := i.GetLocalPath(file.GetOrigin())
|
||||
|
||||
if filepath.Ext(file.Name) == ".tar" || strings.HasSuffix(file.Name, ".tar.gz") || strings.HasSuffix(file.Name, ".tar.bz2") {
|
||||
// Check there is more than 1 file in tarball
|
||||
errs = append(errs, checkTarball(path, file, exceptions)...)
|
||||
errs = append(errs, checkTarball(file, exceptions)...)
|
||||
} else if filepath.Ext(file.Name) == ".zip" {
|
||||
// Check there is more than 1 file in zip
|
||||
errs = append(errs, checkZip(path, file, exceptions)...)
|
||||
errs = append(errs, checkZip(file, exceptions)...)
|
||||
}
|
||||
|
||||
return
|
||||
|
|
Reference in a new issue