-
Notifications
You must be signed in to change notification settings - Fork 669
DYN-6409: Disable PM requests with no-network mode #16191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2dabdd1
11953c9
4f32e6a
292930c
f458121
1793679
0c71b76
cd5d310
be498b8
e971915
f0ce1e3
cbb6ec5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,18 +49,24 @@ public string BaseUrl | |||||||||||||
| get { return this.client.BaseUrl; } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| internal readonly bool NoNetworkMode; | ||||||||||||||
|
|
||||||||||||||
| #endregion | ||||||||||||||
|
|
||||||||||||||
| internal PackageManagerClient(IGregClient client, IPackageUploadBuilder builder, string packageUploadDirectory) | ||||||||||||||
| internal PackageManagerClient(IGregClient client, IPackageUploadBuilder builder, string packageUploadDirectory, | ||||||||||||||
| bool noNetworkMode = false) | ||||||||||||||
| { | ||||||||||||||
| this.packageUploadDirectory = packageUploadDirectory; | ||||||||||||||
| this.uploadBuilder = builder; | ||||||||||||||
| this.client = client; | ||||||||||||||
| this.packageMaintainers = new Dictionary<string, bool>(); | ||||||||||||||
| this.NoNetworkMode = noNetworkMode; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| internal bool Upvote(string packageId) | ||||||||||||||
| { | ||||||||||||||
| if (NoNetworkMode) return false; | ||||||||||||||
|
|
||||||||||||||
| return FailFunc.TryExecute(() => | ||||||||||||||
| { | ||||||||||||||
| var pkgResponse = this.client.ExecuteAndDeserialize(new Upvote(packageId)); | ||||||||||||||
|
|
@@ -70,6 +76,8 @@ internal bool Upvote(string packageId) | |||||||||||||
|
|
||||||||||||||
| internal List<string> UserVotes() | ||||||||||||||
| { | ||||||||||||||
| if (NoNetworkMode) return null; | ||||||||||||||
|
|
||||||||||||||
| var votes = FailFunc.TryExecute(() => | ||||||||||||||
| { | ||||||||||||||
| var nv = new GetUserVotes(); | ||||||||||||||
|
|
@@ -82,6 +90,8 @@ internal List<string> UserVotes() | |||||||||||||
|
|
||||||||||||||
| internal List<JObject> CompatibilityMap() | ||||||||||||||
| { | ||||||||||||||
| if (NoNetworkMode) return null; | ||||||||||||||
|
|
||||||||||||||
| var compatibilityMap = FailFunc.TryExecute(() => | ||||||||||||||
| { | ||||||||||||||
| var cm = new GetCompatibilityMap(); | ||||||||||||||
|
|
@@ -99,6 +109,8 @@ internal PackageManagerResult DownloadPackage(string packageId, string version, | |||||||||||||
| { | ||||||||||||||
| try | ||||||||||||||
| { | ||||||||||||||
| if (NoNetworkMode) throw new Exception(DynamoPackages.Properties.Resources.DownloadPackageDisabled); | ||||||||||||||
|
aparajit-pratap marked this conversation as resolved.
|
||||||||||||||
| if (NoNetworkMode) throw new Exception(DynamoPackages.Properties.Resources.DownloadPackageDisabled); | |
| if (NoNetworkMode) | |
| { | |
| pathToPackage = null; | |
| return PackageManagerResult.Failed(DynamoPackages.Properties.Resources.DownloadPackageDisabled); | |
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning null for a list can lead to NullReferenceExceptions. Prefer returning an empty list (
new List<string>()) to maintain API consistency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This?