Skip to content

Commit e2ebca9

Browse files
chore: improve lookup
1 parent 9e789dc commit e2ebca9

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

agent/agentcontainers/api.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -871,25 +871,23 @@ func (api *API) handleDevcontainerRecreate(w http.ResponseWriter, r *http.Reques
871871

872872
api.mu.Lock()
873873

874-
var workspaceFolder string
875-
for _, dc := range api.knownDevcontainers {
876-
if dc.ID.String() == devcontainerID {
877-
workspaceFolder = dc.WorkspaceFolder
874+
var dc codersdk.WorkspaceAgentDevcontainer
875+
for _, knownDC := range api.knownDevcontainers {
876+
if knownDC.ID.String() == devcontainerID {
877+
dc = knownDC
878878
break
879879
}
880880
}
881-
882-
dc, ok := api.knownDevcontainers[workspaceFolder]
883-
switch {
884-
case !ok:
881+
if dc.ID == uuid.Nil {
885882
api.mu.Unlock()
886883

887884
httpapi.Write(ctx, w, http.StatusNotFound, codersdk.Response{
888885
Message: "Devcontainer not found.",
889886
Detail: fmt.Sprintf("Could not find devcontainer with ID: %q", devcontainerID),
890887
})
891888
return
892-
case dc.Status == codersdk.WorkspaceAgentDevcontainerStatusStarting:
889+
}
890+
if dc.Status == codersdk.WorkspaceAgentDevcontainerStatusStarting {
893891
api.mu.Unlock()
894892

895893
httpapi.Write(ctx, w, http.StatusConflict, codersdk.Response{

0 commit comments

Comments
 (0)