Work on pm restructure
This commit is contained in:
@@ -1,12 +1,44 @@
|
||||
package profile
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/Safing/portbase/database"
|
||||
)
|
||||
|
||||
var (
|
||||
globalProfile *Profile
|
||||
defaultProfile *Profile
|
||||
globalProfile *Profile
|
||||
fallbackProfile *Profile
|
||||
|
||||
specialProfileLock sync.RWMutex
|
||||
)
|
||||
|
||||
// FIXME: subscribe to changes and update profiles
|
||||
func initSpecialProfiles() (err error) {
|
||||
|
||||
specialProfileLock.Lock()
|
||||
defer specialProfileLock.Unlock()
|
||||
|
||||
globalProfile, err = getSpecialProfile("global")
|
||||
if err != nil {
|
||||
if err != database.ErrNotFound {
|
||||
return err
|
||||
}
|
||||
globalProfile = makeDefaultGlobalProfile()
|
||||
globalProfile.Save(specialNamespace)
|
||||
}
|
||||
|
||||
fallbackProfile, err = getSpecialProfile("fallback")
|
||||
if err != nil {
|
||||
if err != database.ErrNotFound {
|
||||
return err
|
||||
}
|
||||
fallbackProfile = makeDefaultFallbackProfile()
|
||||
fallbackProfile.Save(specialNamespace)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getSpecialProfile(ID string) (*Profile, error) {
|
||||
return getProfile(specialNamespace, ID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user