Merge pull request #63 from giesselmann/fix_tag_disabled_repo

fix adding tag with disabled archive
This commit is contained in:
Jan Eitzinger 2022-11-09 14:26:53 +01:00 committed by GitHub
commit 6200190763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -175,7 +175,7 @@ func main() {
log.Fatal("arguments --add-user and --del-user can only be used if authentication is enabled") 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) log.Fatal(err)
} }

View File

@ -32,8 +32,10 @@ type ArchiveBackend interface {
var cache *lrucache.Cache = lrucache.New(128 * 1024 * 1024) var cache *lrucache.Cache = lrucache.New(128 * 1024 * 1024)
var ar ArchiveBackend 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 { var kind struct {
Kind string `json:"kind"` 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. // in that JSON file. If the job is not archived, nothing is done.
func UpdateTags(job *schema.Job, tags []*schema.Tag) error { func UpdateTags(job *schema.Job, tags []*schema.Tag) error {
if job.State == schema.JobStateRunning { if job.State == schema.JobStateRunning || !useArchive {
return nil return nil
} }

View File

@ -284,7 +284,7 @@ func setup(t *testing.T) *api.RestApi {
repository.Connect("sqlite3", dbfilepath) repository.Connect("sqlite3", dbfilepath)
db := repository.GetConnection() 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) t.Fatal(err)
} }