From 8f9acd936766d88746e37b58dd06a23d9c74b46b Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Mon, 20 May 2024 12:34:24 +0200 Subject: [PATCH] added deleting dockerfile before copying --- client/core/controllers/serverController.cpp | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/client/core/controllers/serverController.cpp b/client/core/controllers/serverController.cpp index b66ef5c5f..303ff4000 100644 --- a/client/core/controllers/serverController.cpp +++ b/client/core/controllers/serverController.cpp @@ -416,11 +416,16 @@ ErrorCode ServerController::prepareHostWorker(const ServerCredentials &credentia ErrorCode ServerController::buildContainerWorker(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &config) { - ErrorCode e = uploadFileToHost(credentials, amnezia::scriptData(ProtocolScriptType::dockerfile, container).toUtf8(), - amnezia::server::getDockerfileFolder(container) + "/Dockerfile"); + QString dockerFilePath = amnezia::server::getDockerfileFolder(container) + "/Dockerfile"; + QString scriptString = QString("sudo rm %1").arg(dockerFilePath); + ErrorCode errorCode = runScript(credentials, replaceVars(scriptString, genVarsForScript(credentials, container))); + if (errorCode) + return errorCode; - if (e) - return e; + errorCode = uploadFileToHost(credentials, amnezia::scriptData(ProtocolScriptType::dockerfile, container).toUtf8(),dockerFilePath); + + if (errorCode) + return errorCode; QString stdOut; auto cbReadStdOut = [&](const QString &data, libssh::Client &) { @@ -428,13 +433,13 @@ ErrorCode ServerController::buildContainerWorker(const ServerCredentials &creden return ErrorCode::NoError; }; - e = runScript(credentials, + errorCode = runScript(credentials, replaceVars(amnezia::scriptData(SharedScriptType::build_container), genVarsForScript(credentials, container, config)), cbReadStdOut); - if (e) - return e; + if (errorCode) + return errorCode; - return e; + return errorCode; } ErrorCode ServerController::runContainerWorker(const ServerCredentials &credentials, DockerContainer container, QJsonObject &config)