mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-24 16:11:04 +00:00
Gracefully handle situation when container details have not yet loaded
This should be very rare but it does happen sometimes
This commit is contained in:
parent
623fdb4f33
commit
8a0fcf99f4
1 changed files with 18 additions and 1 deletions
|
|
@ -119,7 +119,24 @@ func (gui *Gui) writeContainerLogs(container *commands.Container, ctx context.Co
|
||||||
}
|
}
|
||||||
defer readCloser.Close()
|
defer readCloser.Close()
|
||||||
|
|
||||||
if container.DetailsLoaded() && container.Details.Config.Tty {
|
if !container.DetailsLoaded() {
|
||||||
|
// loop until the details load or context is cancelled, using timer
|
||||||
|
ticker := time.NewTicker(time.Millisecond * 100)
|
||||||
|
defer ticker.Stop()
|
||||||
|
outer:
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil
|
||||||
|
case <-ticker.C:
|
||||||
|
if container.DetailsLoaded() {
|
||||||
|
break outer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if container.Details.Config.Tty {
|
||||||
_, err = io.Copy(writer, readCloser)
|
_, err = io.Copy(writer, readCloser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue