/// <summary> /// For a client request, gathers applicable leaf bundle updates that the client does not have yet /// </summary> /// <param name="installedNonLeaf">List of non leaf updates installed on the client</param> /// <param name="otherCached">List of other updates known to the client</param> /// <param name="response">The response to append new updates to</param> /// <param name="updatesAdded">On return: true of updates were added to the response, false otherwise</param> private void AddMissingBundleUpdatesToSyncUpdatesResponse(List <Guid> installedNonLeaf, List <Guid> otherCached, SyncInfo response, out bool updatesAdded) { var allMissingBundles = SoftwareLeafUpdateGuids .Except(installedNonLeaf) // Do not resend installed updates .Except(otherCached) // Do not resend other client known updates .Where(guid => IdToFullIdentityMap.ContainsKey(guid)) .Select(guid => IdToFullIdentityMap[guid]) // Map the GUID to a fully qualified identity .Select(id => MetadataSource.UpdatesIndex[id]) // Select the software update by identity .OfType <SoftwareUpdate>() .Where(u => !u.IsSuperseded && u.IsApplicable(installedNonLeaf) && u.IsBundle); // Remove superseded, not applicable and not bundles var unapprovedMissingBundles = allMissingBundles.Where(u => !ApprovedSoftwareUpdates.Contains(u.Identity)); if (unapprovedMissingBundles.Count() > 0) { OnUnApprovedSoftwareUpdatesRequested?.Invoke(unapprovedMissingBundles); } var approvedMissingBundles = allMissingBundles .Where(u => ApprovedSoftwareUpdates.Contains(u.Identity)) .Take(MaxUpdatesInResponse + 1) // Only take the maximum number of updates allowed + 1 (to see if we truncated) .ToList(); if (approvedMissingBundles.Count > 0) { response.NewUpdates = CreateUpdateInfoListFromSoftwareUpdate(approvedMissingBundles).ToArray(); response.Truncated = true; updatesAdded = true; } else { updatesAdded = false; } }
/// <summary> /// For a client request, gathers applicable root updates (detectoids, categories, etc.) that the client does not have yet /// </summary> /// <param name="installedNonLeaf">List of non leaf updates installed on the client</param> /// <param name="otherCached">List of other updates known to the client</param> /// <param name="response">The response to append new updates to</param> /// <param name="updatesAdded">On return: true of updates were added to the response, false otherwise</param> private void AddMissingRootUpdatesToSyncUpdatesResponse(List <Guid> installedNonLeaf, List <Guid> otherCached, SyncInfo response, out bool updatesAdded) { var missingRootUpdates = RootUpdates .Except(installedNonLeaf) // Do not resend installed updates .Except(otherCached) // Do not resend other client known updates .Where(guid => IdToFullIdentityMap.ContainsKey(guid)) .Select(guid => IdToFullIdentityMap[guid]) // Map the GUID to a fully qualified identity .Select(id => MetadataSource.CategoriesIndex[id]) // Get the update (category) by identity .Where(u => !u.IsSuperseded) // Remove superseded updates .Take(MaxUpdatesInResponse + 1) // Only take the maximum number of updates allowed + 1 (to see if we truncated) .ToList(); if (missingRootUpdates.Count > 0) { response.NewUpdates = CreateUpdateInfoListFromNonLeafUpdates(missingRootUpdates).ToArray(); response.Truncated = true; updatesAdded = true; } else { updatesAdded = false; } }
/// <summary> /// For a client request, gathers applicable software updates that are not leafs in the prerequisite tree; /// </summary> /// <param name="installedNonLeaf">List of non leaf updates installed on the client</param> /// <param name="otherCached">List of other updates known to the client</param> /// <param name="response">The response to append new updates to</param> /// <param name="updatesAdded">On return: true of updates were added to the response, false otherwise</param> private void AddMissingNonLeafUpdatesToSyncUpdatesResponse(List <Guid> installedNonLeaf, List <Guid> otherCached, SyncInfo response, out bool updatesAdded) { var missingNonLeafs = NonLeafUpdates .Except(installedNonLeaf) // Do not resend installed updates .Except(otherCached) // Do not resend other client known updates .Where(guid => IdToFullIdentityMap.ContainsKey(guid)) .Select(guid => IdToFullIdentityMap[guid]) // Map the GUID to a fully qualified identity // Non leaf updates can be either a category or regular update .Select(id => MetadataSource.CategoriesIndex.ContainsKey(id) ? MetadataSource.CategoriesIndex[id] : MetadataSource.UpdatesIndex[id]) .Where(u => !u.IsSuperseded && u.IsApplicable(installedNonLeaf)) // Eliminate superseded and not applicable updates .Take(MaxUpdatesInResponse + 1) // Only take the maximum number of updates allowed + 1 (to see if we truncated) .ToList(); if (missingNonLeafs.Count > 0) { response.NewUpdates = CreateUpdateInfoListFromNonLeafUpdates(missingNonLeafs).ToArray(); response.Truncated = true; updatesAdded = true; } else { updatesAdded = false; } }