[fixup] - skip files in the archive handler (#2195)

This commit is contained in:
ahrav 2023-12-08 20:23:32 -08:00 committed by GitHub
parent 2728e514d2
commit 331336dc0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,6 +109,7 @@ func (a *Archive) openArchive(ctx context.Context, depth int, reader io.Reader,
switch archive := format.(type) {
case archiver.Decompressor:
info := decompressorInfo{depth: depth, reader: arReader, archiveChan: archiveChan, archiver: archive}
return a.handleDecompressor(ctx, info)
case archiver.Extractor:
return archive.Extract(context.WithValue(ctx, depthKey, depth+1), reader, nil, a.extractorHandler(archiveChan))
@ -142,8 +143,7 @@ func (a *Archive) handleDecompressor(ctx context.Context, info decompressorInfo)
if err != nil {
return err
}
newReader := bytes.NewReader(fileBytes)
return a.openArchive(ctx, info.depth+1, newReader, info.archiveChan)
return a.openArchive(ctx, info.depth+1, bytes.NewReader(fileBytes), info.archiveChan)
}
// IsFiletype returns true if the provided reader is an archive.
@ -176,13 +176,17 @@ func (a *Archive) extractorHandler(archiveChan chan []byte) func(context.Context
if err != nil {
return err
}
if common.SkipFile(f.Name()) {
logger.V(5).Info("skipping file", "filename", f.Name())
return nil
}
fileBytes, err := a.ReadToMax(ctx, fReader)
if err != nil {
return err
}
fileContent := bytes.NewReader(fileBytes)
err = a.openArchive(ctx, depth, fileContent, archiveChan)
err = a.openArchive(ctx, depth, bytes.NewReader(fileBytes), archiveChan)
if err != nil {
return err
}