Skip to content

Commit

Permalink
Fix Civil3D hostname to fix psuedo warning for package users (DynamoD…
Browse files Browse the repository at this point in the history
…S#13910)

* add cache

* add new host name check

* Update PackageManagerExtension.cs

* Update PackageManagerExtension.cs

* Update PackageManagerExtension.cs

* Update PackageManagerExtension.cs

* Update PackageManagerExtension.cs
  • Loading branch information
zeusongit committed Apr 25, 2023
1 parent 1932a36 commit b459b96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/DynamoPackages/PackageManagerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class PackageManagerClient
#region Properties/Fields

public const string PackageEngineName = "dynamo";
private IEnumerable<string> cachedHosts;

// These were used early on in order to identify packages with binaries and python scripts
// This is now a bona fide field in the DB so they are obsolete.
Expand Down Expand Up @@ -179,12 +180,16 @@ internal virtual PackageVersion GetPackageVersionHeader(string id, string versio
/// </summary>
internal virtual IEnumerable<string> GetKnownHosts()
{
return FailFunc.TryExecute(() =>
if (cachedHosts == null)
{
var hosts = new Hosts();
var hostsResponse = this.client.ExecuteAndDeserializeWithContent<List<String>>(hosts);
return hostsResponse.content;
}, new List<string>());
cachedHosts = FailFunc.TryExecute(() =>
{
var hosts = new Hosts();
var hostsResponse = this.client.ExecuteAndDeserializeWithContent<List<String>>(hosts);
return hostsResponse.content;
}, new List<string>());
}
return cachedHosts;
}

internal bool GetTermsOfUseAcceptanceStatus()
Expand Down
7 changes: 3 additions & 4 deletions src/DynamoPackages/PackageManagerExtension.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using Dynamo.Configuration;
using Dynamo.Extensions;
using Dynamo.Graph.Workspaces;
using Dynamo.Interfaces;
Expand Down Expand Up @@ -357,7 +355,8 @@ internal bool CheckIfPackagesTargetOtherHosts(IEnumerable<PackageVersion> newPac
{
// Is our host in the list?
// If not, is any other host in the list?
return x.host_dependencies != null && !x.host_dependencies.Contains(Host) && otherHosts.Any(y => x.host_dependencies.Contains(y));
// Also, check if any dependency contains the hostname or vice-versa.
return x.host_dependencies != null && !x.host_dependencies.Contains(Host) && !x.host_dependencies.Any(y => Host.Contains(y)) && otherHosts.Any(y => x.host_dependencies.Contains(y));
});
}

Expand Down

0 comments on commit b459b96

Please sign in to comment.