From 0de13688584cf1c1bd025eada420db6afe0bd509 Mon Sep 17 00:00:00 2001 From: Pay Giesselmann Date: Tue, 8 Nov 2022 16:49:45 +0100 Subject: [PATCH] fix adding tag with disabled archive --- cmd/cc-backend/main.go | 2 +- pkg/archive/archive.go | 6 ++++-- test/integration_test.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/cc-backend/main.go b/cmd/cc-backend/main.go index 9c7ce34..daf3ca9 100644 --- a/cmd/cc-backend/main.go +++ b/cmd/cc-backend/main.go @@ -175,7 +175,7 @@ func main() { log.Fatal("arguments --add-user and --del-user can only be used if authentication is enabled") } - if err := archive.Init(config.Keys.Archive); err != nil { + if err := archive.Init(config.Keys.Archive, config.Keys.DisableArchive); err != nil { log.Fatal(err) } diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index d4d1582..5bec30e 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -32,8 +32,10 @@ type ArchiveBackend interface { var cache *lrucache.Cache = lrucache.New(128 * 1024 * 1024) var ar ArchiveBackend +var useArchive bool -func Init(rawConfig json.RawMessage) error { +func Init(rawConfig json.RawMessage, disableArchive bool) error { + useArchive = !disableArchive var kind struct { Kind string `json:"kind"` } @@ -96,7 +98,7 @@ func GetStatistics(job *schema.Job) (map[string]schema.JobStatistics, error) { // in that JSON file. If the job is not archived, nothing is done. func UpdateTags(job *schema.Job, tags []*schema.Tag) error { - if job.State == schema.JobStateRunning { + if job.State == schema.JobStateRunning || !useArchive { return nil } diff --git a/test/integration_test.go b/test/integration_test.go index abafe08..a7753fd 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -284,7 +284,7 @@ func setup(t *testing.T) *api.RestApi { repository.Connect("sqlite3", dbfilepath) db := repository.GetConnection() - if err := archive.Init(json.RawMessage(archiveCfg)); err != nil { + if err := archive.Init(json.RawMessage(archiveCfg), config.Keys.DisableArchive); err != nil { t.Fatal(err) }