From 2362879f5f74c9687a1905c7c7bc6a6819456e7a Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Tue, 7 Mar 2023 11:08:32 +0100 Subject: [PATCH] version check fixed in stand-alone execution --- image/app/dataverse/version.go | 11 +++++++++-- image/app/local/main.go | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/image/app/dataverse/version.go b/image/app/dataverse/version.go index 390c9d8..02a28a6 100644 --- a/image/app/dataverse/version.go +++ b/image/app/dataverse/version.go @@ -16,7 +16,7 @@ import ( type dvVersion string -var version = getVersion() +var version dvVersion var filesCleanup = "5.13" var urlSigning = "https://github.com/IQSS/dataverse/pull/9383" // needs delete via native api and upload zip via native api to work @@ -25,6 +25,13 @@ var slashInPermissions = "https://github.com/IQSS/dataverse/pull/8995" // will b var nativeApiDelete = "https://github.com/IQSS/dataverse/pull/9383" // will be replaced with verion when pull request is merged func init() { + if config.GetConfig().DataverseServer != "" { + Init() + } +} + +func Init() { + version = getVersion() if version.GreaterOrEqual(filesCleanup) { logging.Logger.Printf("version %v >= %v: files cleanup feature is on", version, filesCleanup) filesCleanup = "true" @@ -64,7 +71,7 @@ func getVersion() dvVersion { defer r.Body.Close() b, _ := io.ReadAll(r.Body) res := VersionResponse{} - if r.StatusCode != 200 || res.Status != "OK" { + if r.StatusCode != 200 { logging.Logger.Println("error when getting version:", res.Message) } json.Unmarshal(b, &res) diff --git a/image/app/local/main.go b/image/app/local/main.go index 73605f6..8d89342 100644 --- a/image/app/local/main.go +++ b/image/app/local/main.go @@ -7,6 +7,7 @@ import ( "flag" "fmt" "integration/app/config" + "integration/app/dataverse" "integration/app/destination" "integration/app/frontend" "integration/app/logging" @@ -61,6 +62,7 @@ func main() { MaxFileSize = *maxFileSize mfs, _ := strconv.Atoi(MaxFileSize) config.SetConfig(DataverseServer, RootDataverseId, DefaultHash, roles, true, int64(mfs)) + dataverse.Init() frontend.Config.DataverseHeader = DataverseServerName frontend.Config.Plugins = append([]config.RepoPlugin{{ Id: "local",