Skip to content

Commit 331336d

Browse files
authored
[fixup] - skip files in the archive handler (#2195)
1 parent 2728e51 commit 331336d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/handlers/archive.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func (a *Archive) openArchive(ctx context.Context, depth int, reader io.Reader,
109109
switch archive := format.(type) {
110110
case archiver.Decompressor:
111111
info := decompressorInfo{depth: depth, reader: arReader, archiveChan: archiveChan, archiver: archive}
112+
112113
return a.handleDecompressor(ctx, info)
113114
case archiver.Extractor:
114115
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)
142143
if err != nil {
143144
return err
144145
}
145-
newReader := bytes.NewReader(fileBytes)
146-
return a.openArchive(ctx, info.depth+1, newReader, info.archiveChan)
146+
return a.openArchive(ctx, info.depth+1, bytes.NewReader(fileBytes), info.archiveChan)
147147
}
148148

149149
// IsFiletype returns true if the provided reader is an archive.
@@ -176,13 +176,17 @@ func (a *Archive) extractorHandler(archiveChan chan []byte) func(context.Context
176176
if err != nil {
177177
return err
178178
}
179+
if common.SkipFile(f.Name()) {
180+
logger.V(5).Info("skipping file", "filename", f.Name())
181+
return nil
182+
}
183+
179184
fileBytes, err := a.ReadToMax(ctx, fReader)
180185
if err != nil {
181186
return err
182187
}
183-
fileContent := bytes.NewReader(fileBytes)
184188

185-
err = a.openArchive(ctx, depth, fileContent, archiveChan)
189+
err = a.openArchive(ctx, depth, bytes.NewReader(fileBytes), archiveChan)
186190
if err != nil {
187191
return err
188192
}

0 commit comments

Comments
 (0)