Skip to content

Commit ca21e7c

Browse files
committed
Restore packs after purge in rpc mode
1 parent 3a59136 commit ca21e7c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

tools/projmgr/src/ProjMgrRpcServer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ RpcArgs::SuccessResult RpcHandler::LoadPacks(void) {
322322
RpcArgs::SuccessResult RpcHandler::LoadSolution(const string& solution, const string& activeTarget) {
323323
m_bUseAllPacks = false; // loading solution will first use only listed packs
324324
m_packReferences.clear(); // will be updated
325+
m_manager.Clear();
325326
m_solutionLoaded = false; // assume not loaded yet
326327
auto globalModel = ProjMgrKernel::Get()->GetGlobalModel();
327328
// remove non-existing and explicit packs
@@ -338,6 +339,13 @@ RpcArgs::SuccessResult RpcHandler::LoadSolution(const string& solution, const st
338339
result.message = solution + " is not a *.csolution.yml file";
339340
return result;
340341
}
342+
if(purged) {
343+
// we need to add available packs to model again (the packs are already loaded)
344+
m_worker.InitializeModel();
345+
m_worker.SetLoadPacksPolicy(LoadPacksPolicy::ALL);
346+
result.success = m_worker.LoadAllRelevantPacks();
347+
m_worker.SetLoadPacksPolicy(LoadPacksPolicy::DEFAULT);
348+
}
341349
// we disregard return value of m_manager.LoadSolution() here, because we tolerate some errors
342350
m_manager.LoadSolution(csolutionFile, activeTarget);
343351
map<string, ContextItem>* contexts = nullptr;
@@ -880,6 +888,7 @@ RpcArgs::ConvertSolutionResult RpcHandler::ConvertSolution(const string& solutio
880888
m_bUseAllPacks = false; // loading solution will first use only listed packs
881889
m_packReferences.clear(); // will be updated
882890
m_solutionLoaded = false; // assume not loaded
891+
m_manager.Clear();
883892
auto globalModel = ProjMgrKernel::Get()->GetGlobalModel();
884893
// remove non-existing and explicit packs
885894
// clear model and projects if at least one pack is deleted

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ bool ProjMgrWorker::LoadAllRelevantPacks() {
548548
return false;
549549
}
550550
// Get installed packs
551-
if (m_rpcMode || pdscFiles.empty() || (m_loadPacksPolicy == LoadPacksPolicy::ALL) || (m_loadPacksPolicy == LoadPacksPolicy::LATEST)) {
551+
if (pdscFiles.empty() || (m_loadPacksPolicy == LoadPacksPolicy::ALL) || (m_loadPacksPolicy == LoadPacksPolicy::LATEST)) {
552552
const bool latest = (m_loadPacksPolicy == LoadPacksPolicy::LATEST) || (m_loadPacksPolicy == LoadPacksPolicy::DEFAULT);
553553
if (!m_kernel->GetEffectivePdscFiles(pdscFiles, latest)) {
554554
ProjMgrLogger::Get().Error("parsing installed packs failed");

0 commit comments

Comments
 (0)