gui: resolve session/agent names from IDs before building 9P paths
killSession, renameSession, readLogForSession, getAgents, and
renameAgent were using immutable IDs directly in paths like
session/{id}/ctl. The 9P namespace uses the mutable display name
as the directory key, not the ID. Use sessionNameForId() and
agentNameForId() consistently (matching agentPath()).
This commit is contained in:
parent
34d4a97b3d
commit
042f287796
|
|
@ -363,7 +363,11 @@ QString Ollie9pClient::readLog()
|
||||||
QString Ollie9pClient::readLogForSession(const QString &sessionId, const QString &agentId)
|
QString Ollie9pClient::readLogForSession(const QString &sessionId, const QString &agentId)
|
||||||
{
|
{
|
||||||
if (sessionId.isEmpty() || agentId.isEmpty()) return {};
|
if (sessionId.isEmpty() || agentId.isEmpty()) return {};
|
||||||
QByteArray out = run9p({"read", "session/" + sessionId + "/agent/" + agentId + "/log"});
|
QString sessName = sessionNameForId(sessionId);
|
||||||
|
if (sessName.isEmpty()) sessName = sessionId;
|
||||||
|
QString agentName = agentNameForId(sessionId, agentId);
|
||||||
|
if (agentName.isEmpty()) agentName = agentId;
|
||||||
|
QByteArray out = run9p({"read", "session/" + sessName + "/agent/" + agentName + "/log"});
|
||||||
return QString::fromUtf8(out);
|
return QString::fromUtf8(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,7 +416,11 @@ bool Ollie9pClient::killSession(const QString &sessionId)
|
||||||
stopStreams();
|
stopStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString path = "session/" + sessionId + "/ctl";
|
// Resolve the directory name from the immutable session ID
|
||||||
|
QString sessName = sessionNameForId(sessionId);
|
||||||
|
if (sessName.isEmpty()) sessName = sessionId;
|
||||||
|
|
||||||
|
QString path = "session/" + sessName + "/ctl";
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.start(ninepBin(), {"-a", serverAddr(), "write", path});
|
proc.start(ninepBin(), {"-a", serverAddr(), "write", path});
|
||||||
proc.waitForStarted(3000);
|
proc.waitForStarted(3000);
|
||||||
|
|
@ -432,7 +440,9 @@ QString Ollie9pClient::getConfig()
|
||||||
QStringList Ollie9pClient::getAgents(const QString &sessionId)
|
QStringList Ollie9pClient::getAgents(const QString &sessionId)
|
||||||
{
|
{
|
||||||
if (sessionId.isEmpty()) return {};
|
if (sessionId.isEmpty()) return {};
|
||||||
QByteArray out = run9p({"ls", "session/" + sessionId + "/agent"});
|
QString sessName = sessionNameForId(sessionId);
|
||||||
|
if (sessName.isEmpty()) sessName = sessionId;
|
||||||
|
QByteArray out = run9p({"ls", "session/" + sessName + "/agent"});
|
||||||
QString raw = QString::fromUtf8(out).trimmed();
|
QString raw = QString::fromUtf8(out).trimmed();
|
||||||
if (raw.isEmpty()) return {};
|
if (raw.isEmpty()) return {};
|
||||||
QStringList all = raw.split('\n', Qt::SkipEmptyParts);
|
QStringList all = raw.split('\n', Qt::SkipEmptyParts);
|
||||||
|
|
@ -596,9 +606,13 @@ bool Ollie9pClient::renameSession(const QString &sessionId, const QString &newNa
|
||||||
// Session names are mutable display names, not directory IDs. Writing the
|
// Session names are mutable display names, not directory IDs. Writing the
|
||||||
// name file also avoids relying on Twstat, which is not implemented by all
|
// name file also avoids relying on Twstat, which is not implemented by all
|
||||||
// 9P frontends.
|
// 9P frontends.
|
||||||
|
// Resolve the directory name from the immutable session ID
|
||||||
|
QString sessName = sessionNameForId(sessionId);
|
||||||
|
if (sessName.isEmpty()) sessName = sessionId;
|
||||||
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.setProgram(bin);
|
proc.setProgram(bin);
|
||||||
proc.setArguments({"-a", serverAddr(), "write", "session/" + sessionId + "/name"});
|
proc.setArguments({"-a", serverAddr(), "write", "session/" + sessName + "/name"});
|
||||||
proc.start();
|
proc.start();
|
||||||
if (!proc.waitForStarted(3000)) {
|
if (!proc.waitForStarted(3000)) {
|
||||||
qDebug() << "renameSession failed to start:" << proc.errorString();
|
qDebug() << "renameSession failed to start:" << proc.errorString();
|
||||||
|
|
@ -649,10 +663,16 @@ bool Ollie9pClient::renameAgent(const QString &sessionId, const QString &agentId
|
||||||
if (active)
|
if (active)
|
||||||
stopAgentStreams();
|
stopAgentStreams();
|
||||||
|
|
||||||
|
// Resolve directory names from immutable IDs
|
||||||
|
QString sessName = sessionNameForId(sessionId);
|
||||||
|
if (sessName.isEmpty()) sessName = sessionId;
|
||||||
|
QString agentName = agentNameForId(sessionId, agentId);
|
||||||
|
if (agentName.isEmpty()) agentName = agentId;
|
||||||
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.setProgram(bin);
|
proc.setProgram(bin);
|
||||||
proc.setArguments({"-a", serverAddr(), "write",
|
proc.setArguments({"-a", serverAddr(), "write",
|
||||||
"session/" + sessionId + "/agent/" + agentId + "/name"});
|
"session/" + sessName + "/agent/" + agentName + "/name"});
|
||||||
proc.start();
|
proc.start();
|
||||||
if (!proc.waitForStarted(3000)) {
|
if (!proc.waitForStarted(3000)) {
|
||||||
qDebug() << "renameAgent failed to start:" << proc.errorString();
|
qDebug() << "renameAgent failed to start:" << proc.errorString();
|
||||||
|
|
|
||||||
Reference in New Issue