mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
Break out non-autocomplete changes from autocomplete PR (#618)
This improves the ephemeral command runner to allow for honoring of timeouts and proper handling of overriding the current working directory. It also fixes some partially transparent font colors in light mode, making them solid instead. It also updates the InputModel to be auto-observable and utilize some getters to ensure the cmdinput is getting updated whenever necessary state changes take place.
This commit is contained in:
@@ -926,12 +926,11 @@ func RunCommandSimple(pk *packet.RunPacketType, sender *packet.PacketSender, fro
|
||||
rcFileName = fmt.Sprintf("/dev/fd/%d", rcFileFdNum)
|
||||
}
|
||||
if cmd.TmpRcFileName != "" {
|
||||
go func() {
|
||||
time.AfterFunc(2*time.Second, func() {
|
||||
// cmd.Close() will also remove rcFileName
|
||||
// adding this to also try to proactively clean up after 2-seconds.
|
||||
time.Sleep(2 * time.Second)
|
||||
os.Remove(cmd.TmpRcFileName)
|
||||
}()
|
||||
})
|
||||
}
|
||||
fullCmdStr := pk.Command
|
||||
if pk.ReturnState {
|
||||
@@ -1109,6 +1108,14 @@ func RunCommandSimple(pk *packet.RunPacketType, sender *packet.PacketSender, fro
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if pk.Timeout > 0 {
|
||||
// Cancel the command if it takes too long
|
||||
time.AfterFunc(pk.Timeout, func() {
|
||||
cmd.Cmd.Cancel()
|
||||
cmd.Close()
|
||||
})
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user