@@ -93,15 +93,6 @@ func RedactResult(bundlePath string, input CollectorResult, additionalRedactors
93
93
readerCloseFn = func () error { return nil } // No-op for in-memory data
94
94
}
95
95
96
- // Ensure the reader is closed after processing
97
- defer func () {
98
- if err := readerCloseFn (); err != nil {
99
- klog .Warningf ("Failed to close reader for %s: %v" , file , err )
100
- errorCh <- errors .Wrap (err , "failed to close reader" )
101
- return
102
- }
103
- }()
104
-
105
96
// If the file is .tar, .tgz or .tar.gz, it must not be redacted. Instead it is
106
97
// decompressed and each file inside the tar redacted and compressed back into the archive.
107
98
if filepath .Ext (file ) == ".tar" || filepath .Ext (file ) == ".tgz" || strings .HasSuffix (file , ".tar.gz" ) {
@@ -117,6 +108,14 @@ func RedactResult(bundlePath string, input CollectorResult, additionalRedactors
117
108
errorCh <- errors .Wrap (err , "failed to decompress file" )
118
109
return
119
110
}
111
+
112
+ // Ensure the reader is closed after processing
113
+ if err := readerCloseFn (); err != nil {
114
+ klog .Warningf ("Failed to close reader for %s: %v" , file , err )
115
+ errorCh <- errors .Wrap (err , "failed to close reader" )
116
+ return
117
+ }
118
+
120
119
err = RedactResult (tmpDir , subResult , additionalRedactors )
121
120
if err != nil {
122
121
errorCh <- errors .Wrap (err , "failed to redact file" )
0 commit comments