From 9cc2815754e36aaf276d60bed08d1f24609a21b5 Mon Sep 17 00:00:00 2001 From: netbenix Date: Tue, 30 Nov 2021 07:21:52 +0100 Subject: [PATCH] fix(SQL): Added missing option to not use SQL --- SQL/SQLInterface.go | 17 ++++++++++++++--- Tools/Config.go | 3 ++- config/config.json | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/SQL/SQLInterface.go b/SQL/SQLInterface.go index f0cebc4..a80ce67 100644 --- a/SQL/SQLInterface.go +++ b/SQL/SQLInterface.go @@ -13,20 +13,31 @@ type SQLService interface { } func CreateDefaultTables(sqlService SQLService){ - sqlService.createDefaultTables() + config := Tools.GetConfig() + if config.SQLConfig.EnableSQL{ + sqlService.createDefaultTables() + } } func NewLogEntry(sqlService SQLService, uuid uuid.UUID, logType LogType, backupName string, stage SQLStage, storageType RemoteStorageType, description string, timestamp time.Time){ - sqlService.newLogEntry(uuid, logType, backupName, stage, storageType, description, timestamp) + config := Tools.GetConfig() + if config.SQLConfig.EnableSQL{ + sqlService.newLogEntry(uuid, logType, backupName, stage, storageType, description, timestamp) + } } func NewBackupEntry(sqlService SQLService, backupName string, lastBackup time.Time, localBackup bool, filePath string, storageType RemoteStorageType, remotePath string){ - sqlService.newBackupEntry(backupName, lastBackup, localBackup, filePath, storageType, remotePath) + config := Tools.GetConfig() + if config.SQLConfig.EnableSQL{ + sqlService.newBackupEntry(backupName, lastBackup, localBackup, filePath, storageType, remotePath) + } } func GetSQLInstance() SQLService{ config := Tools.GetConfig() + if !config.SQLConfig.EnableSQL { return nil } + switch config.SQLConfig.SqlType { case "mariadb": {return GetMariaDBInstance(config)} } diff --git a/Tools/Config.go b/Tools/Config.go index 216a48b..49fe55e 100644 --- a/Tools/Config.go +++ b/Tools/Config.go @@ -9,7 +9,8 @@ import ( type Config struct { LocalBackupPath string `json:"localBackupPath"` SQLConfig struct{ - SqlType string `json:"sqlType"` + EnableSQL bool `json:"enableSQL"` + SqlType string `json:"sqlType"` SqlAddress string `json:"sql-address"` SqlPort uint16 `json:"sql-port"` Database string `json:"database"` diff --git a/config/config.json b/config/config.json index 3b5b69a..b2368c1 100644 --- a/config/config.json +++ b/config/config.json @@ -1,7 +1,7 @@ { "localBackupPath": "", "sqlConfig": { - "sqlType": "", + "enableSQL": false, "sql-address": "", "sql-port": 0, "database": "",