@@ -218,9 +218,7 @@ func (s *Server) listenForMsgs(shutdownCh chan struct{}, sub *kbchat.Subscriptio
218218 }
219219 continue
220220 case strings .HasPrefix (cmd , fmt .Sprintf ("!%s" , feedbackCmd (s .kbc .GetUsername ()))):
221- if err := s .handleFeedback (msg ); err != nil {
222- s .Errorf ("listenForMsgs: unable to handleFeedback: %v" , err )
223- }
221+ s .handleFeedback (msg )
224222 continue
225223 }
226224 }
@@ -291,7 +289,7 @@ func (s *Server) handleLogSend(msg chat1.MsgSummary) error {
291289 }
292290 outputBytes , err := io .ReadAll (output )
293291 if err != nil {
294- s .Errorf ("unable to read ouput : %v" , err )
292+ s .Errorf ("unable to read output : %v" , err )
295293 return err
296294 }
297295 if len (outputBytes ) > 0 {
@@ -345,8 +343,8 @@ func (s *Server) handlePProf(msg chat1.MsgSummary) error {
345343 // Cleanup after the file is sent.
346344 time .Sleep (time .Minute )
347345 s .Debug ("cleaning up %s" , outfile )
348- if err = os .Remove (outfile ); err != nil {
349- s .Errorf ("unable to clean up %s: %v" , outfile , err )
346+ if rmErr : = os .Remove (outfile ); rmErr != nil {
347+ s .Errorf ("unable to clean up %s: %v" , outfile , rmErr )
350348 }
351349 }()
352350 if _ , err := s .kbc .SendAttachmentByConvID (msg .ConvID , outfile , "" ); err != nil {
@@ -389,7 +387,7 @@ func (s *Server) handleStack(msg chat1.MsgSummary) error {
389387 return s .kbfsDebugOutput (msg , stack , "stack" )
390388}
391389
392- func (s * Server ) handleFeedback (msg chat1.MsgSummary ) error {
390+ func (s * Server ) handleFeedback (msg chat1.MsgSummary ) {
393391 toks := strings .Split (strings .TrimSpace (msg .Content .Text .Body ), " " )
394392 if len (toks ) < 3 {
395393 s .ChatEcho (msg .ConvID , "Woah there @%s, I can't deliver a blank message...not again. What did you want to say?" ,
@@ -400,7 +398,6 @@ func (s *Server) handleFeedback(msg chat1.MsgSummary) error {
400398 s .ChatEcho (msg .ConvID , "Roger that @%s, passed this along to my humans :robot_face:" ,
401399 msg .Sender .Username )
402400 }
403- return nil
404401}
405402
406403func (s * Server ) kbfsDebugOutput (msg chat1.MsgSummary , data []byte , operation string ) error {
@@ -415,8 +412,12 @@ func (s *Server) kbfsDebugOutput(msg chat1.MsgSummary, data []byte, operation st
415412 }
416413 fileName := fmt .Sprintf ("%s-%d.txt" , operation , time .Now ().Unix ())
417414 filePath := fmt .Sprintf ("/tmp/%s" , fileName )
418- defer os .Remove (filePath )
419- if err := os .WriteFile (filePath , data , 0644 ); err != nil {
415+ defer func () {
416+ if rmErr := os .Remove (filePath ); rmErr != nil {
417+ s .Errorf ("unable to clean up %s: %v" , filePath , rmErr )
418+ }
419+ }()
420+ if err := os .WriteFile (filePath , data , 0o600 ); err != nil {
420421 return fmt .Errorf ("kbfsOutput: failed to write %s output: %s" , operation , err )
421422 }
422423 if err := s .runOptions .Command ("fs" , "mv" , filePath , folder ).Run (); err != nil {
0 commit comments