fix: out of bounds error, closes [#8]
use .is_some() and if let Some() to make sure that container indexes are still valid, without can cause out of bounds issue due to docker update frequencies
This commit is contained in:
@@ -160,7 +160,7 @@ impl DockerControls {
|
||||
match state {
|
||||
State::Dead | State::Exited => vec![Self::Start, Self::Restart],
|
||||
State::Paused => vec![Self::Unpause, Self::Stop],
|
||||
State::Restarting => vec![Self::Stop],
|
||||
State::Restarting => vec![Self::Stop],
|
||||
State::Running => vec![Self::Pause, Self::Restart, Self::Stop],
|
||||
_ => vec![],
|
||||
}
|
||||
|
||||
+4
-2
@@ -304,8 +304,10 @@ impl AppData {
|
||||
if self.containers.state.selected().is_some() {
|
||||
self.containers.previous();
|
||||
}
|
||||
// docker rm -f $(docker ps -aq) will cause this to crash
|
||||
self.containers.items.remove(index);
|
||||
// Check is some, else can cause out of bounds error, if containers get removed before a docker update
|
||||
if self.containers.items.get(index).is_some() {
|
||||
self.containers.items.remove(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user