From 7ca93cec6cc5b1f58e053122666b56b011e7f5e5 Mon Sep 17 00:00:00 2001 From: ish Date: Mon, 18 Nov 2024 20:16:13 +0900 Subject: [PATCH] software: Check the number of custom configs --- lib/software/install.go | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/software/install.go b/lib/software/install.go index 5aa684f..30f8502 100644 --- a/lib/software/install.go +++ b/lib/software/install.go @@ -108,21 +108,24 @@ func MigrateSoftware(executionID string, executionList *[]model.MigrationSoftwar return } - migrationLogger.Printf(INFO, "Starting to copy custom configs") - var customConfigs []ConfigFile - for _, customConfig := range strings.Split(sw.CustomConfigs, ",") { - customConfigs = append(customConfigs, ConfigFile{ - Path: customConfig, - Status: "Custom", - }) - } - err = copyConfigFiles(s, t, customConfigs) - if err != nil { - logger.Println(logger.ERROR, true, "migrateSoftware: ExecutionID="+executionID+ - ", SoftwareID="+execution.SoftwareID+", Error="+err.Error()) - updateStatus(i, "failed", err.Error(), false) - - return + customConfigsSplit := strings.Split(sw.CustomConfigs, ",") + if len(customConfigsSplit) > 0 { + migrationLogger.Printf(INFO, "Starting to copy custom configs") + var customConfigs []ConfigFile + for _, customConfig := range customConfigsSplit { + customConfigs = append(customConfigs, ConfigFile{ + Path: customConfig, + Status: "Custom", + }) + } + err = copyConfigFiles(s, t, customConfigs) + if err != nil { + logger.Println(logger.ERROR, true, "migrateSoftware: ExecutionID="+executionID+ + ", SoftwareID="+execution.SoftwareID+", Error="+err.Error()) + updateStatus(i, "failed", err.Error(), false) + + return + } } err = serviceMigrator(s, t, execution.SoftwareName, executionID)