File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
lib/agent/actions/logretrieval Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -82,19 +82,28 @@ exports.collectFiles = (outputFile, cb) => {
8282 return ;
8383 }
8484 array . push ( ( callback ) => {
85- let fileData ;
85+ let fileData = '' ;
8686 const rs = fs . createReadStream ( file . path ) ;
8787 rs . on ( 'error' , ( ) => {
8888 callback ( ) ;
8989 } ) ;
9090
9191 rs . on ( 'data' , ( data ) => {
92- if ( fileData ) fileData = fileData . toString ( ) . concat ( data ) ;
93- else fileData = data ;
92+ try {
93+ if ( ! data ) logger . info ( `There was an error reading file ${ file . name } : no data` ) ;
94+ if ( fileData ) fileData = fileData . toString ( ) . concat ( data ) ;
95+ else fileData = data ;
96+ } catch ( error ) {
97+ logger . info ( `There was an error reading file ${ file . name } : ${ error } ` ) ;
98+ }
9499 } ) ;
95100
96101 rs . on ( 'close' , ( ) => {
97- archive . append ( fileData , { name : file . name } ) ;
102+ try {
103+ archive . append ( fileData || '' , { name : file . name } ) ;
104+ } catch ( error ) {
105+ logger . info ( `There was an error appending file ${ file . name } to archive: ${ error } ` ) ;
106+ }
98107 callback ( ) ;
99108 } ) ;
100109 } ) ;
You can’t perform that action at this time.
0 commit comments