{"action":"created","comment":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/199623443","pull_request_review_id":133778497,"id":199623443,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTYyMzQ0Mw==","diff_hunk":"@@ -534,48 +553,79 @@ func renterfilesdeletecmd(path string) {\n // Downloads a path from the Sia network to the local specified destination.\n func renterfilesdownloadcmd(path, destination string) {\n \tdestination = abs(destination)\n-\tvar err error\n-\tdone := make(chan struct{})\n-\tgo func() {\n-\t\terr = httpClient.RenterDownloadFullGet(path, destination, renterDownloadAsync)\n-\t\tclose(done)\n-\t}()\n-\tdownloadprogress(done, path)\n+\n+\t// Queue the download. An error will be returned if the queueing failed, but\n+\t// the call will return before the download has completed. The call is made\n+\t// as an async call.\n+\terr := httpClient.RenterDownloadFullGet(path, destination, true)\n+\tif err != nil {\n+\t\tdie(\"Download could not be started:\", err)\n+\t}\n+\n+\t// If the download is async, report success.\n+\tif renterDownloadAsync {\n+\t\tfmt.Printf(\"Queued Download '%s' to %s.\\n\", path, abs(destination))\n+\t\treturn\n+\t}\n+\n+\t// If the download is blocking, display progress as the file downloads.\n+\terr = downloadprogress(path)\n \tif err != nil {\n-\t\tdie(\"Could not download file:\", err)\n+\t\tdie(\"\\nDownload could not be completed:\", err)\n \t}\n \tfmt.Printf(\"\\nDownloaded '%s' to %s.\\n\", path, abs(destination))\n }\n \n-func downloadprogress(done chan struct{}, siapath string) {\n-\ttime.Sleep(time.Second) // give download time to initialize\n-\tfor {\n-\t\tselect {\n-\t\tcase <-done:\n-\t\t\treturn\n+// downloadprogress will display the progress of the provided download to the\n+// user, and return an error when the download is finished.\n+func downloadprogress(siapath string) error {\n+\t// If the download does not appear after a long time, give up.\n+\tvar tryTime time.Duration\n \n-\t\tcase <-time.Tick(time.Second):\n-\t\t\t// get download progress of file\n-\t\t\tqueue, err := httpClient.RenterDownloadsGet()\n-\t\t\tif err != nil {\n-\t\t\t\tcontinue // benign\n-\t\t\t}\n-\t\t\tvar d api.DownloadInfo\n-\t\t\tfor _, d = range queue.Downloads {\n-\t\t\t\tif d.SiaPath == siapath {\n-\t\t\t\t\tbreak\n-\t\t\t\t}\n+\tfor range time.Tick(OutputRefreshRate) {\n+\t\t// Get the list of downloads.\n+\t\tqueue, err := httpClient.RenterDownloadsGet()\n+\t\tif err != nil {\n+\t\t\tcontinue // benign\n+\t\t}\n+\n+\t\t// Search for the download in the list of downloads.\n+\t\tvar d api.DownloadInfo\n+\t\tfound := false\n+\t\tfor _, d = range queue.Downloads {\n+\t\t\tif d.SiaPath == siapath {\n+\t\t\t\tfound = true\n+\t\t\t\tbreak\n \t\t\t}\n-\t\t\tif d.Filesize == 0 {\n-\t\t\t\tcontinue // file hasn't appeared in queue yet\n+\t\t}\n+\t\t// If the download has not appeared in the queue yet, either continue or\n+\t\t// give up.\n+\t\tif !found {\n+\t\t\ttryTime += OutputRefreshRate\n+\t\t\tif tryTime > time.Minute {","path":"cmd/siac/rentercmd.go","position":112,"original_position":112,"commit_id":"3bfa33289ebc552619513016404904d7714e5494","original_commit_id":"3bfa33289ebc552619513016404904d7714e5494","user":{"login":"ChrisSchinnerl","id":3903476,"node_id":"MDQ6VXNlcjM5MDM0NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/3903476?v=4","gravatar_id":"","url":"https://api.github.com/users/ChrisSchinnerl","html_url":"https://github.com/ChrisSchinnerl","followers_url":"https://api.github.com/users/ChrisSchinnerl/followers","following_url":"https://api.github.com/users/ChrisSchinnerl/following{/other_user}","gists_url":"https://api.github.com/users/ChrisSchinnerl/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisSchinnerl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisSchinnerl/subscriptions","organizations_url":"https://api.github.com/users/ChrisSchinnerl/orgs","repos_url":"https://api.github.com/users/ChrisSchinnerl/repos","events_url":"https://api.github.com/users/ChrisSchinnerl/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisSchinnerl/received_events","type":"User","site_admin":false},"body":"Should this also be a constant instead of just `time.Minute` ?","created_at":"2018-07-02T21:15:39Z","updated_at":"2018-07-02T21:19:38Z","html_url":"https://github.com/NebulousLabs/Sia/pull/3137#discussion_r199623443","pull_request_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments/199623443"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/3137#discussion_r199623443"},"pull_request":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137"}}},"pull_request":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137","id":198746773,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NzQ2Nzcz","html_url":"https://github.com/NebulousLabs/Sia/pull/3137","diff_url":"https://github.com/NebulousLabs/Sia/pull/3137.diff","patch_url":"https://github.com/NebulousLabs/Sia/pull/3137.patch","issue_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/3137","number":3137,"state":"open","locked":false,"title":"clean up siac renter download","user":{"login":"DavidVorick","id":2316841,"node_id":"MDQ6VXNlcjIzMTY4NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/2316841?v=4","gravatar_id":"","url":"https://api.github.com/users/DavidVorick","html_url":"https://github.com/DavidVorick","followers_url":"https://api.github.com/users/DavidVorick/followers","following_url":"https://api.github.com/users/DavidVorick/following{/other_user}","gists_url":"https://api.github.com/users/DavidVorick/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidVorick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidVorick/subscriptions","organizations_url":"https://api.github.com/users/DavidVorick/orgs","repos_url":"https://api.github.com/users/DavidVorick/repos","events_url":"https://api.github.com/users/DavidVorick/events{/privacy}","received_events_url":"https://api.github.com/users/DavidVorick/received_events","type":"User","site_admin":false},"body":"Wasn't happy with the implementation.\r\n\r\nI removed the unnecessary 1 second sleep, switched it so that there are no goroutines or channels needed, and I added some extra safety stuff like a timer for a potential infinite loop.\r\n\r\nI also added a bunch of TODOs for things that aren't fully done correctly in the code yet.","created_at":"2018-07-02T17:43:24Z","updated_at":"2018-07-02T21:19:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b5c96df154bb7f7b67585c00b4e8e1cc07f7c27c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137/commits","review_comments_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137/comments","review_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/3137/comments","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/3bfa33289ebc552619513016404904d7714e5494","head":{"label":"NebulousLabs:siac-dla","ref":"siac-dla","sha":"3bfa33289ebc552619513016404904d7714e5494","user":{"login":"NebulousLabs","id":7471422,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0NzE0MjI=","avatar_url":"https://avatars1.githubusercontent.com/u/7471422?v=4","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"node_id":"MDEwOlJlcG9zaXRvcnkyNTM3MDA3Mg==","name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0NzE0MjI=","avatar_url":"https://avatars1.githubusercontent.com/u/7471422?v=4","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","deployments_url":"https://api.github.com/repos/NebulousLabs/Sia/deployments","created_at":"2014-10-17T17:50:25Z","updated_at":"2018-07-02T20:15:03Z","pushed_at":"2018-07-02T21:16:10Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"https://sia.tech","size":18215,"stargazers_count":2737,"watchers_count":2737,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":444,"mirror_url":null,"archived":false,"open_issues_count":161,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":444,"open_issues":161,"watchers":2737,"default_branch":"master"}},"base":{"label":"NebulousLabs:master","ref":"master","sha":"4c73a7ddd05f8e80d345b341328ec6c03ecd2e7b","user":{"login":"NebulousLabs","id":7471422,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0NzE0MjI=","avatar_url":"https://avatars1.githubusercontent.com/u/7471422?v=4","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":25370072,"node_id":"MDEwOlJlcG9zaXRvcnkyNTM3MDA3Mg==","name":"Sia","full_name":"NebulousLabs/Sia","owner":{"login":"NebulousLabs","id":7471422,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0NzE0MjI=","avatar_url":"https://avatars1.githubusercontent.com/u/7471422?v=4","gravatar_id":"","url":"https://api.github.com/users/NebulousLabs","html_url":"https://github.com/NebulousLabs","followers_url":"https://api.github.com/users/NebulousLabs/followers","following_url":"https://api.github.com/users/NebulousLabs/following{/other_user}","gists_url":"https://api.github.com/users/NebulousLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/NebulousLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NebulousLabs/subscriptions","organizations_url":"https://api.github.com/users/NebulousLabs/orgs","repos_url":"https://api.github.com/users/NebulousLabs/repos","events_url":"https://api.github.com/users/NebulousLabs/events{/privacy}","received_events_url":"https://api.github.com/users/NebulousLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NebulousLabs/Sia","description":"Blockchain-based marketplace for file storage","fork":false,"url":"https://api.github.com/repos/NebulousLabs/Sia","forks_url":"https://api.github.com/repos/NebulousLabs/Sia/forks","keys_url":"https://api.github.com/repos/NebulousLabs/Sia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NebulousLabs/Sia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NebulousLabs/Sia/teams","hooks_url":"https://api.github.com/repos/NebulousLabs/Sia/hooks","issue_events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/events{/number}","events_url":"https://api.github.com/repos/NebulousLabs/Sia/events","assignees_url":"https://api.github.com/repos/NebulousLabs/Sia/assignees{/user}","branches_url":"https://api.github.com/repos/NebulousLabs/Sia/branches{/branch}","tags_url":"https://api.github.com/repos/NebulousLabs/Sia/tags","blobs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NebulousLabs/Sia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NebulousLabs/Sia/git/refs{/sha}","trees_url":"https://api.github.com/repos/NebulousLabs/Sia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NebulousLabs/Sia/statuses/{sha}","languages_url":"https://api.github.com/repos/NebulousLabs/Sia/languages","stargazers_url":"https://api.github.com/repos/NebulousLabs/Sia/stargazers","contributors_url":"https://api.github.com/repos/NebulousLabs/Sia/contributors","subscribers_url":"https://api.github.com/repos/NebulousLabs/Sia/subscribers","subscription_url":"https://api.github.com/repos/NebulousLabs/Sia/subscription","commits_url":"https://api.github.com/repos/NebulousLabs/Sia/commits{/sha}","git_commits_url":"https://api.github.com/repos/NebulousLabs/Sia/git/commits{/sha}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/comments{/number}","issue_comment_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments{/number}","contents_url":"https://api.github.com/repos/NebulousLabs/Sia/contents/{+path}","compare_url":"https://api.github.com/repos/NebulousLabs/Sia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NebulousLabs/Sia/merges","archive_url":"https://api.github.com/repos/NebulousLabs/Sia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NebulousLabs/Sia/downloads","issues_url":"https://api.github.com/repos/NebulousLabs/Sia/issues{/number}","pulls_url":"https://api.github.com/repos/NebulousLabs/Sia/pulls{/number}","milestones_url":"https://api.github.com/repos/NebulousLabs/Sia/milestones{/number}","notifications_url":"https://api.github.com/repos/NebulousLabs/Sia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/labels{/name}","releases_url":"https://api.github.com/repos/NebulousLabs/Sia/releases{/id}","deployments_url":"https://api.github.com/repos/NebulousLabs/Sia/deployments","created_at":"2014-10-17T17:50:25Z","updated_at":"2018-07-02T20:15:03Z","pushed_at":"2018-07-02T21:16:10Z","git_url":"git://github.com/NebulousLabs/Sia.git","ssh_url":"git@github.com:NebulousLabs/Sia.git","clone_url":"https://github.com/NebulousLabs/Sia.git","svn_url":"https://github.com/NebulousLabs/Sia","homepage":"https://sia.tech","size":18215,"stargazers_count":2737,"watchers_count":2737,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":444,"mirror_url":null,"archived":false,"open_issues_count":161,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":444,"open_issues":161,"watchers":2737,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137"},"html":{"href":"https://github.com/NebulousLabs/Sia/pull/3137"},"issue":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/3137"},"comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/issues/3137/comments"},"review_comments":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137/comments"},"review_comment":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NebulousLabs/Sia/pulls/3137/commits"},"statuses":{"href":"https://api.github.com/repos/NebulousLabs/Sia/statuses/3bfa33289ebc552619513016404904d7714e5494"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ChrisSchinnerl"}}