Restart Init

This commit is contained in:
Simon Martens
2026-02-18 13:41:44 +01:00
parent 938cdeb27b
commit 4f4288905d
2955 changed files with 4795 additions and 53375 deletions

View File

@@ -1,40 +1,7 @@
package xmlmodels
import (
"sync"
import gitpkg "github.com/Theodor-Springmann-Stiftung/lenz-web/git"
"github.com/Theodor-Springmann-Stiftung/lenz-web/xmlparsing"
)
var lib *Library
var mu sync.RWMutex
func Set(l *Library) {
mu.Lock()
defer mu.Unlock()
if lib != nil {
panic("Trying to reinitialize Library")
}
lib = l
}
func Get() *Library {
mu.RLock()
defer mu.RUnlock()
if lib == nil {
panic("Trying to get uninitialized Library")
}
return lib
}
func Parse(dir, hash string) (*Library, error) {
if lib == nil {
Set(NewLibrary())
}
if hash == "" {
return Get(), lib.Parse(xmlparsing.Path, dir, hash)
}
return Get(), lib.Parse(xmlparsing.Commit, dir, hash)
func Parse(dir string, commit *gitpkg.Commit) (*Library, error) {
return NewLibrary(dir, commit)
}