repochecker/*-inspector: Refactor file opening

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

View file

@ -7,20 +7,19 @@ import (
"fmt"
"io"
"log"
"os"
"strings"
"srs.epita.fr/fic-server/admin/sync"
"srs.epita.fr/fic-server/libfic"
)
func checkTarball(path string, file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
fd, err := os.Open(path)
func checkTarball(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
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()
var rd io.Reader
if strings.HasSuffix(file.Name, ".tar.gz") {