Fix layered profiles not readable via the API

This commit is contained in:
Patrick Pacher
2020-10-30 16:43:49 +01:00
parent c0509042a0
commit fb6b34ebe5
4 changed files with 75 additions and 30 deletions

View File

@@ -16,18 +16,26 @@ var (
activeProfilesLock sync.RWMutex
)
// getActiveProfile returns a cached copy of an active profile and nil if it isn't found.
// getActiveProfile returns a cached copy of an active profile and
// nil if it isn't found.
func getActiveProfile(scopedID string) *Profile {
activeProfilesLock.RLock()
defer activeProfilesLock.RUnlock()
activeProfile, ok := activeProfiles[scopedID]
if ok {
activeProfile.MarkStillActive()
return activeProfile
return activeProfiles[scopedID]
}
// getAllActiveProfiles returns a slice of active profiles.
func getAllActiveProfiles() []*Profile {
activeProfilesLock.RLock()
defer activeProfilesLock.RUnlock()
result := make([]*Profile, 0, len(activeProfiles))
for _, p := range activeProfiles {
result = append(result, p)
}
return nil
return result
}
// findActiveProfile searched for an active local profile using the linked path.