Improve handling of layered profile on profile update

This commit is contained in:
Daniel
2022-02-15 16:07:29 +01:00
parent 3be1c78e16
commit d491e51127
3 changed files with 14 additions and 6 deletions

View File

@@ -14,9 +14,7 @@ var getProfileLock sync.Mutex
// GetProfile fetches a profile. This function ensures that the loaded profile
// is shared among all callers. You must always supply both the scopedID and
// linkedPath parameters whenever available. The linkedPath is used as the key
// for locking concurrent requests, so it must be supplied if available.
// If linkedPath is not supplied, source and id make up the key instead.
// linkedPath parameters whenever available.
func GetProfile(source profileSource, id, linkedPath string, reset bool) ( //nolint:gocognit
profile *Profile,
err error,
@@ -112,6 +110,7 @@ func GetProfile(source profileSource, id, linkedPath string, reset bool) ( //nol
// Add a layeredProfile to local and network profiles.
if profile.Source == SourceLocal || profile.Source == SourceNetwork {
// If we are refetching, assign the layered profile from the previous version.
// The internal references will be updated when the layered profile checks for updates.
if previousVersion != nil {
profile.layeredProfile = previousVersion.layeredProfile
}