{"action":"created","comment":{"url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments/49936181","id":49936181,"diff_hunk":"@@ -38,34 +40,58 @@ public DownloadResourceV2(V2Resource resource)\n                 throw new ArgumentNullException(nameof(identity));\n             }\n \n+            string uri = string.Empty;\n+\n             return Task.Run(() =>\n             {\n                 token.ThrowIfCancellationRequested();\n \n-                try\n+                for (int i = 0; i < 3; i++)\n                 {\n-                    var sourcePackage = identity as SourcePackageDependencyInfo;\n-                    var repository = V2Client as DataServicePackageRepository;\n+                    try\n+                    {\n+                        var sourcePackage = identity as SourcePackageDependencyInfo;\n+                        var repository = V2Client as DataServicePackageRepository;\n+\n+                        bool isFromUri = repository != null\n+                            && sourcePackage?.PackageHash != null\n+                            && sourcePackage?.DownloadUri != null;\n+\n+                        if (isFromUri)\n+                        {\n+                            uri = sourcePackage?.DownloadUri.AbsoluteUri;\n+                        }\n+                        else\n+                        {\n+                            uri = (repository as DataServicePackageRepository)?.Source ?? \"Folder\";\n+                        }\n \n-                    if (repository != null\n-                        && sourcePackage?.PackageHash != null\n-                        && sourcePackage?.DownloadUri != null)\n+                        if (isFromUri)\n+                        {\n+                            // If this is a SourcePackageDependencyInfo object with everything populated\n+                            // and it is from an online source, use the machine cache and download it using the\n+                            // given url.\n+                            return DownloadFromUrl(sourcePackage, repository, token);\n+                        }\n+                        else\n+                        {\n+                            // Look up the package from the id and version and download it.\n+                            return DownloadFromIdentity(identity, V2Client, token);\n+                        }\n+                    }\n+                    catch (IOException ex) when (ex.InnerException is SocketException && i < 2)\n                     {\n-                        // If this is a SourcePackageDependencyInfo object with everything populated\n-                        // and it is from an online source, use the machine cache and download it using the\n-                        // given url.\n-                        return DownloadFromUrl(sourcePackage, repository, token);\n+                        string message = $\"Error downloading {identity} from {uri} {ExceptionUtilities.DisplayMessage(ex)}\";\n+\n+                        Logger.Instance.LogWarning(message);","path":"src/NuGet.Core/NuGet.Protocol.Core.v2/DownloadResourceV2.cs","position":68,"original_position":68,"commit_id":"487358456cf3278536bf1aba06adb232811a1cf2","original_commit_id":"487358456cf3278536bf1aba06adb232811a1cf2","user":{"login":"emgarten","id":6381138,"avatar_url":"https://avatars.githubusercontent.com/u/6381138?v=3","gravatar_id":"","url":"https://api.github.com/users/emgarten","html_url":"https://github.com/emgarten","followers_url":"https://api.github.com/users/emgarten/followers","following_url":"https://api.github.com/users/emgarten/following{/other_user}","gists_url":"https://api.github.com/users/emgarten/gists{/gist_id}","starred_url":"https://api.github.com/users/emgarten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emgarten/subscriptions","organizations_url":"https://api.github.com/users/emgarten/orgs","repos_url":"https://api.github.com/users/emgarten/repos","events_url":"https://api.github.com/users/emgarten/events{/privacy}","received_events_url":"https://api.github.com/users/emgarten/received_events","type":"User","site_admin":false},"body":"This will end up going to the null logger in VS I believe, which is okay I would say.","created_at":"2016-01-16T19:40:27Z","updated_at":"2016-01-16T19:40:27Z","html_url":"https://github.com/NuGet/NuGet.Client/pull/202#discussion_r49936181","pull_request_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202","_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments/49936181"},"html":{"href":"https://github.com/NuGet/NuGet.Client/pull/202#discussion_r49936181"},"pull_request":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202"}}},"pull_request":{"url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202","id":56236410,"html_url":"https://github.com/NuGet/NuGet.Client/pull/202","diff_url":"https://github.com/NuGet/NuGet.Client/pull/202.diff","patch_url":"https://github.com/NuGet/NuGet.Client/pull/202.patch","issue_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/202","number":202,"state":"open","locked":false,"title":"Add retry logic for failed downloads because of broken TCP connections","user":{"login":"yishaigalatzer","id":1238711,"avatar_url":"https://avatars.githubusercontent.com/u/1238711?v=3","gravatar_id":"","url":"https://api.github.com/users/yishaigalatzer","html_url":"https://github.com/yishaigalatzer","followers_url":"https://api.github.com/users/yishaigalatzer/followers","following_url":"https://api.github.com/users/yishaigalatzer/following{/other_user}","gists_url":"https://api.github.com/users/yishaigalatzer/gists{/gist_id}","starred_url":"https://api.github.com/users/yishaigalatzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yishaigalatzer/subscriptions","organizations_url":"https://api.github.com/users/yishaigalatzer/orgs","repos_url":"https://api.github.com/users/yishaigalatzer/repos","events_url":"https://api.github.com/users/yishaigalatzer/events{/privacy}","received_events_url":"https://api.github.com/users/yishaigalatzer/received_events","type":"User","site_admin":false},"body":"Make protocol exception be specifically retriable or fatal\r\nAdd error messages for failed downloads\r\nAdd logging\r\nRefactor and clean some files\r\n\r\nAdd common exception message cleanup","created_at":"2016-01-15T23:52:16Z","updated_at":"2016-01-16T19:40:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15f415c2bf568370d8c122b03987cf5928208fe8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202/commits","review_comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202/comments","review_comment_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/202/comments","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/487358456cf3278536bf1aba06adb232811a1cf2","head":{"label":"NuGet:DownloadErrorHandling","ref":"DownloadErrorHandling","sha":"487358456cf3278536bf1aba06adb232811a1cf2","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":19330736,"name":"NuGet.Client","full_name":"NuGet/NuGet.Client","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.Client","description":"Core client libraries for NuGet Services","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.Client","forks_url":"https://api.github.com/repos/NuGet/NuGet.Client/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.Client/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.Client/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.Client/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.Client/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.Client/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.Client/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.Client/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.Client/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.Client/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.Client/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.Client/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.Client/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.Client/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.Client/releases{/id}","created_at":"2014-04-30T23:46:11Z","updated_at":"2016-01-16T10:01:59Z","pushed_at":"2016-01-16T08:59:58Z","git_url":"git://github.com/NuGet/NuGet.Client.git","ssh_url":"git@github.com:NuGet/NuGet.Client.git","clone_url":"https://github.com/NuGet/NuGet.Client.git","svn_url":"https://github.com/NuGet/NuGet.Client","homepage":null,"size":16222,"stargazers_count":26,"watchers_count":26,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":15,"forks":35,"open_issues":15,"watchers":26,"default_branch":"dev"}},"base":{"label":"NuGet:dev","ref":"dev","sha":"975096df8414f5b0e26adb435f4ee5081cd9a463","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":19330736,"name":"NuGet.Client","full_name":"NuGet/NuGet.Client","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.Client","description":"Core client libraries for NuGet Services","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.Client","forks_url":"https://api.github.com/repos/NuGet/NuGet.Client/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.Client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.Client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.Client/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.Client/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.Client/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.Client/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.Client/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.Client/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.Client/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.Client/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.Client/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.Client/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.Client/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.Client/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.Client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.Client/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.Client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.Client/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.Client/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.Client/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.Client/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.Client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.Client/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.Client/releases{/id}","created_at":"2014-04-30T23:46:11Z","updated_at":"2016-01-16T10:01:59Z","pushed_at":"2016-01-16T08:59:58Z","git_url":"git://github.com/NuGet/NuGet.Client.git","ssh_url":"git@github.com:NuGet/NuGet.Client.git","clone_url":"https://github.com/NuGet/NuGet.Client.git","svn_url":"https://github.com/NuGet/NuGet.Client","homepage":null,"size":16222,"stargazers_count":26,"watchers_count":26,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":15,"forks":35,"open_issues":15,"watchers":26,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202"},"html":{"href":"https://github.com/NuGet/NuGet.Client/pull/202"},"issue":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/issues/202"},"comments":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/issues/202/comments"},"review_comments":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202/comments"},"review_comment":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/pulls/202/commits"},"statuses":{"href":"https://api.github.com/repos/NuGet/NuGet.Client/statuses/487358456cf3278536bf1aba06adb232811a1cf2"}}}}