fix: remove container even if already removed

This commit is contained in:
2025-09-25 15:28:35 -06:00
parent 407c1a1c9b
commit a66843714d

View File

@@ -915,6 +915,19 @@ class ContainerManager:
self.session_manager.remove_session(session.id)
return True
except DockerException as e:
error_message = str(e).lower()
# If container is not running or already removed, still remove it from session list
if (
"is not running" in error_message
or "no such container" in error_message
or "not found" in error_message
):
print(
f"Container already stopped/removed, removing session {session.id} from list"
)
self.session_manager.remove_session(session.id)
return True
else:
print(f"Error closing session {session.id}: {e}")
return False
@@ -980,6 +993,25 @@ class ContainerManager:
return True
except DockerException as e:
error_message = str(e).lower()
# If container is not running or already removed, still remove it from session list
if (
"is not running" in error_message
or "no such container" in error_message
or "not found" in error_message
):
print(
f"Container already stopped/removed, removing session {session.id} from list"
)
self.session_manager.remove_session(session.id)
if progress_callback:
progress_callback(
session.id,
"completed",
f"{session.name} removed from list (container already stopped)",
)
return True
else:
error_msg = f"Error: {str(e)}"
if progress_callback:
progress_callback(session.id, "failed", error_msg)