From 0207fa04f1630cac520a78b332ca3efc6b8b1edf Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Wed, 15 Feb 2023 17:56:56 +0100 Subject: [PATCH] feat(GODT-2364): wait and retry once if the gRPC service config file exists but cannot be opened. --- .../bridge-gui/bridgepp/bridgepp/GRPC/GRPCConfig.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCConfig.cpp b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCConfig.cpp index 7092d539..17414112 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCConfig.cpp +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/GRPC/GRPCConfig.cpp @@ -78,10 +78,13 @@ bool GRPCConfig::load(QString const &path, QString *outError) { try { QFile file(path); if (!file.exists()) - throw Exception("The file service configuration file does not exist."); + throw Exception("The gRPC service configuration file does not exist."); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - throw Exception("The file exists but cannot be opened."); + QThread::msleep(500); // we wait a bit and retry once, just in case server is not done writing/moving the config file. + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + throw Exception("The gRPC service configuration file exists but cannot be opened."); + } } QJsonDocument const doc = QJsonDocument::fromJson(file.readAll());