in packages/packages.go [148:175]
func NewZipFileSystemIndexer(logger *zap.Logger, paths ...string) *FileSystemIndexer {
walkerFn := func(basePath, path string, info os.DirEntry) (bool, error) {
if info.IsDir() {
return false, nil
}
if !strings.HasSuffix(path, ".zip") {
return false, nil
}
// Check if the file is actually a zip file.
r, err := zip.OpenReader(path)
if err != nil {
logger.Warn("ignoring invalid zip file",
zap.String("file.path", path), zap.Error(err))
return false, nil
}
defer r.Close()
return true, nil
}
return &FileSystemIndexer{
paths: paths,
label: "ZipFileSystemIndexer",
walkerFn: walkerFn,
fsBuilder: ZipFileSystemBuilder,
logger: logger,
}
}