{"action":"created","comment":{"url":"https://api.github.com/repos/rvcevans/adventofcode/pulls/comments/93759565","pull_request_review_id":14294234,"id":93759565,"diff_hunk":"@@ -31,8 +35,39 @@ func Get(year int, day int, sessionKey string) ([]string, error) {\n \tif err != nil {\n \t\treturn nil, err\n \t}\n+\treturn contents, nil\n+}\n+\n+func Get(year int, day int, sessionKey string) ([]string, error) {\n+\tcacheFilename := filepath.Join(os.TempDir(), \"advent\", strconv.Itoa(day))\n+\n+\tvar b []byte\n+\tif _, err := os.Stat(cacheFilename); os.IsNotExist(err) {\n+\t\tif sessionKey == \"\" {\n+\t\t\treturn nil, errors.New(\"no session key provided\")\n+\t\t}\n+\t\terr := os.MkdirAll(filepath.Dir(cacheFilename), 0777)\n+\t\tif err != nil {\n+\t\t\treturn nil, fmt.Errorf(\"could not create advent cache dir: %v\", err)\n+\t\t}\n+\n+\t\tb, err = get(year, day, sessionKey)\n+\t\tif err != nil {\n+\t\t\treturn nil, fmt.Errorf(\"error fetching puzzle: %v\", err)\n+\t\t}\n+\t\tif err := ioutil.WriteFile(cacheFilename, b, 0777); err != nil {\n+\t\t\treturn nil, fmt.Errorf(\"error saving puzzle: %v\", err)\n+\t\t}\n+\n+\t} else {\n+\t\tvar err error","path":"getinput/getinput.go","position":50,"original_position":50,"commit_id":"46716837bd84bb463712fdc7fb86bb561b2b9d4c","original_commit_id":"46716837bd84bb463712fdc7fb86bb561b2b9d4c","user":{"login":"rvcevans","id":11234099,"avatar_url":"https://avatars.githubusercontent.com/u/11234099?v=3","gravatar_id":"","url":"https://api.github.com/users/rvcevans","html_url":"https://github.com/rvcevans","followers_url":"https://api.github.com/users/rvcevans/followers","following_url":"https://api.github.com/users/rvcevans/following{/other_user}","gists_url":"https://api.github.com/users/rvcevans/gists{/gist_id}","starred_url":"https://api.github.com/users/rvcevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvcevans/subscriptions","organizations_url":"https://api.github.com/users/rvcevans/orgs","repos_url":"https://api.github.com/users/rvcevans/repos","events_url":"https://api.github.com/users/rvcevans/events{/privacy}","received_events_url":"https://api.github.com/users/rvcevans/received_events","type":"User","site_admin":false},"body":"redundant line?","created_at":"2016-12-23T12:17:04Z","updated_at":"2016-12-23T12:17:04Z","html_url":"https://github.com/rvcevans/adventofcode/pull/3#discussion_r93759565","pull_request_url":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/rvcevans/adventofcode/pulls/comments/93759565"},"html":{"href":"https://github.com/rvcevans/adventofcode/pull/3#discussion_r93759565"},"pull_request":{"href":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3","id":99191642,"html_url":"https://github.com/rvcevans/adventofcode/pull/3","diff_url":"https://github.com/rvcevans/adventofcode/pull/3.diff","patch_url":"https://github.com/rvcevans/adventofcode/pull/3.patch","issue_url":"https://api.github.com/repos/rvcevans/adventofcode/issues/3","number":3,"state":"open","locked":false,"title":"getinput: cache puzzle input","user":{"login":"ifross89","id":3983918,"avatar_url":"https://avatars.githubusercontent.com/u/3983918?v=3","gravatar_id":"","url":"https://api.github.com/users/ifross89","html_url":"https://github.com/ifross89","followers_url":"https://api.github.com/users/ifross89/followers","following_url":"https://api.github.com/users/ifross89/following{/other_user}","gists_url":"https://api.github.com/users/ifross89/gists{/gist_id}","starred_url":"https://api.github.com/users/ifross89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifross89/subscriptions","organizations_url":"https://api.github.com/users/ifross89/orgs","repos_url":"https://api.github.com/users/ifross89/repos","events_url":"https://api.github.com/users/ifross89/events{/privacy}","received_events_url":"https://api.github.com/users/ifross89/received_events","type":"User","site_admin":false},"body":"Add cache to puzzle input by saving body in temp directory.\r\n\r\nAlso return error if no session key is provided and there is no cached body.","created_at":"2016-12-23T00:50:34Z","updated_at":"2016-12-23T12:17:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cb7d9668845e67b826da04b3e09d51241bb0be6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3/commits","review_comments_url":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3/comments","review_comment_url":"https://api.github.com/repos/rvcevans/adventofcode/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rvcevans/adventofcode/issues/3/comments","statuses_url":"https://api.github.com/repos/rvcevans/adventofcode/statuses/46716837bd84bb463712fdc7fb86bb561b2b9d4c","head":{"label":"ifross89:patch-2","ref":"patch-2","sha":"46716837bd84bb463712fdc7fb86bb561b2b9d4c","user":{"login":"ifross89","id":3983918,"avatar_url":"https://avatars.githubusercontent.com/u/3983918?v=3","gravatar_id":"","url":"https://api.github.com/users/ifross89","html_url":"https://github.com/ifross89","followers_url":"https://api.github.com/users/ifross89/followers","following_url":"https://api.github.com/users/ifross89/following{/other_user}","gists_url":"https://api.github.com/users/ifross89/gists{/gist_id}","starred_url":"https://api.github.com/users/ifross89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifross89/subscriptions","organizations_url":"https://api.github.com/users/ifross89/orgs","repos_url":"https://api.github.com/users/ifross89/repos","events_url":"https://api.github.com/users/ifross89/events{/privacy}","received_events_url":"https://api.github.com/users/ifross89/received_events","type":"User","site_admin":false},"repo":{"id":47399298,"name":"adventofcode","full_name":"ifross89/adventofcode","owner":{"login":"ifross89","id":3983918,"avatar_url":"https://avatars.githubusercontent.com/u/3983918?v=3","gravatar_id":"","url":"https://api.github.com/users/ifross89","html_url":"https://github.com/ifross89","followers_url":"https://api.github.com/users/ifross89/followers","following_url":"https://api.github.com/users/ifross89/following{/other_user}","gists_url":"https://api.github.com/users/ifross89/gists{/gist_id}","starred_url":"https://api.github.com/users/ifross89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ifross89/subscriptions","organizations_url":"https://api.github.com/users/ifross89/orgs","repos_url":"https://api.github.com/users/ifross89/repos","events_url":"https://api.github.com/users/ifross89/events{/privacy}","received_events_url":"https://api.github.com/users/ifross89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ifross89/adventofcode","description":"Answers to 2015's adventofcode","fork":true,"url":"https://api.github.com/repos/ifross89/adventofcode","forks_url":"https://api.github.com/repos/ifross89/adventofcode/forks","keys_url":"https://api.github.com/repos/ifross89/adventofcode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ifross89/adventofcode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ifross89/adventofcode/teams","hooks_url":"https://api.github.com/repos/ifross89/adventofcode/hooks","issue_events_url":"https://api.github.com/repos/ifross89/adventofcode/issues/events{/number}","events_url":"https://api.github.com/repos/ifross89/adventofcode/events","assignees_url":"https://api.github.com/repos/ifross89/adventofcode/assignees{/user}","branches_url":"https://api.github.com/repos/ifross89/adventofcode/branches{/branch}","tags_url":"https://api.github.com/repos/ifross89/adventofcode/tags","blobs_url":"https://api.github.com/repos/ifross89/adventofcode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ifross89/adventofcode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ifross89/adventofcode/git/refs{/sha}","trees_url":"https://api.github.com/repos/ifross89/adventofcode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ifross89/adventofcode/statuses/{sha}","languages_url":"https://api.github.com/repos/ifross89/adventofcode/languages","stargazers_url":"https://api.github.com/repos/ifross89/adventofcode/stargazers","contributors_url":"https://api.github.com/repos/ifross89/adventofcode/contributors","subscribers_url":"https://api.github.com/repos/ifross89/adventofcode/subscribers","subscription_url":"https://api.github.com/repos/ifross89/adventofcode/subscription","commits_url":"https://api.github.com/repos/ifross89/adventofcode/commits{/sha}","git_commits_url":"https://api.github.com/repos/ifross89/adventofcode/git/commits{/sha}","comments_url":"https://api.github.com/repos/ifross89/adventofcode/comments{/number}","issue_comment_url":"https://api.github.com/repos/ifross89/adventofcode/issues/comments{/number}","contents_url":"https://api.github.com/repos/ifross89/adventofcode/contents/{+path}","compare_url":"https://api.github.com/repos/ifross89/adventofcode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ifross89/adventofcode/merges","archive_url":"https://api.github.com/repos/ifross89/adventofcode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ifross89/adventofcode/downloads","issues_url":"https://api.github.com/repos/ifross89/adventofcode/issues{/number}","pulls_url":"https://api.github.com/repos/ifross89/adventofcode/pulls{/number}","milestones_url":"https://api.github.com/repos/ifross89/adventofcode/milestones{/number}","notifications_url":"https://api.github.com/repos/ifross89/adventofcode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ifross89/adventofcode/labels{/name}","releases_url":"https://api.github.com/repos/ifross89/adventofcode/releases{/id}","deployments_url":"https://api.github.com/repos/ifross89/adventofcode/deployments","created_at":"2015-12-04T11:10:25Z","updated_at":"2015-12-04T11:10:26Z","pushed_at":"2016-12-22T23:55:12Z","git_url":"git://github.com/ifross89/adventofcode.git","ssh_url":"git@github.com:ifross89/adventofcode.git","clone_url":"https://github.com/ifross89/adventofcode.git","svn_url":"https://github.com/ifross89/adventofcode","homepage":null,"size":38,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rvcevans:master","ref":"master","sha":"ac43095630cab502118d92de97f28fbfd3b23d29","user":{"login":"rvcevans","id":11234099,"avatar_url":"https://avatars.githubusercontent.com/u/11234099?v=3","gravatar_id":"","url":"https://api.github.com/users/rvcevans","html_url":"https://github.com/rvcevans","followers_url":"https://api.github.com/users/rvcevans/followers","following_url":"https://api.github.com/users/rvcevans/following{/other_user}","gists_url":"https://api.github.com/users/rvcevans/gists{/gist_id}","starred_url":"https://api.github.com/users/rvcevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvcevans/subscriptions","organizations_url":"https://api.github.com/users/rvcevans/orgs","repos_url":"https://api.github.com/users/rvcevans/repos","events_url":"https://api.github.com/users/rvcevans/events{/privacy}","received_events_url":"https://api.github.com/users/rvcevans/received_events","type":"User","site_admin":false},"repo":{"id":47330129,"name":"adventofcode","full_name":"rvcevans/adventofcode","owner":{"login":"rvcevans","id":11234099,"avatar_url":"https://avatars.githubusercontent.com/u/11234099?v=3","gravatar_id":"","url":"https://api.github.com/users/rvcevans","html_url":"https://github.com/rvcevans","followers_url":"https://api.github.com/users/rvcevans/followers","following_url":"https://api.github.com/users/rvcevans/following{/other_user}","gists_url":"https://api.github.com/users/rvcevans/gists{/gist_id}","starred_url":"https://api.github.com/users/rvcevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvcevans/subscriptions","organizations_url":"https://api.github.com/users/rvcevans/orgs","repos_url":"https://api.github.com/users/rvcevans/repos","events_url":"https://api.github.com/users/rvcevans/events{/privacy}","received_events_url":"https://api.github.com/users/rvcevans/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rvcevans/adventofcode","description":"Answers to adventofcode","fork":false,"url":"https://api.github.com/repos/rvcevans/adventofcode","forks_url":"https://api.github.com/repos/rvcevans/adventofcode/forks","keys_url":"https://api.github.com/repos/rvcevans/adventofcode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rvcevans/adventofcode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rvcevans/adventofcode/teams","hooks_url":"https://api.github.com/repos/rvcevans/adventofcode/hooks","issue_events_url":"https://api.github.com/repos/rvcevans/adventofcode/issues/events{/number}","events_url":"https://api.github.com/repos/rvcevans/adventofcode/events","assignees_url":"https://api.github.com/repos/rvcevans/adventofcode/assignees{/user}","branches_url":"https://api.github.com/repos/rvcevans/adventofcode/branches{/branch}","tags_url":"https://api.github.com/repos/rvcevans/adventofcode/tags","blobs_url":"https://api.github.com/repos/rvcevans/adventofcode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rvcevans/adventofcode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rvcevans/adventofcode/git/refs{/sha}","trees_url":"https://api.github.com/repos/rvcevans/adventofcode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rvcevans/adventofcode/statuses/{sha}","languages_url":"https://api.github.com/repos/rvcevans/adventofcode/languages","stargazers_url":"https://api.github.com/repos/rvcevans/adventofcode/stargazers","contributors_url":"https://api.github.com/repos/rvcevans/adventofcode/contributors","subscribers_url":"https://api.github.com/repos/rvcevans/adventofcode/subscribers","subscription_url":"https://api.github.com/repos/rvcevans/adventofcode/subscription","commits_url":"https://api.github.com/repos/rvcevans/adventofcode/commits{/sha}","git_commits_url":"https://api.github.com/repos/rvcevans/adventofcode/git/commits{/sha}","comments_url":"https://api.github.com/repos/rvcevans/adventofcode/comments{/number}","issue_comment_url":"https://api.github.com/repos/rvcevans/adventofcode/issues/comments{/number}","contents_url":"https://api.github.com/repos/rvcevans/adventofcode/contents/{+path}","compare_url":"https://api.github.com/repos/rvcevans/adventofcode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rvcevans/adventofcode/merges","archive_url":"https://api.github.com/repos/rvcevans/adventofcode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rvcevans/adventofcode/downloads","issues_url":"https://api.github.com/repos/rvcevans/adventofcode/issues{/number}","pulls_url":"https://api.github.com/repos/rvcevans/adventofcode/pulls{/number}","milestones_url":"https://api.github.com/repos/rvcevans/adventofcode/milestones{/number}","notifications_url":"https://api.github.com/repos/rvcevans/adventofcode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rvcevans/adventofcode/labels{/name}","releases_url":"https://api.github.com/repos/rvcevans/adventofcode/releases{/id}","deployments_url":"https://api.github.com/repos/rvcevans/adventofcode/deployments","created_at":"2015-12-03T12:19:31Z","updated_at":"2016-12-02T17:50:43Z","pushed_at":"2016-12-23T00:50:35Z","git_url":"git://github.com/rvcevans/adventofcode.git","ssh_url":"git@github.com:rvcevans/adventofcode.git","clone_url":"https://github.com/rvcevans/adventofcode.git","svn_url":"https://github.com/rvcevans/adventofcode","homepage":"","size":37,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3"},"html":{"href":"https://github.com/rvcevans/adventofcode/pull/3"},"issue":{"href":"https://api.github.com/repos/rvcevans/adventofcode/issues/3"},"comments":{"href":"https://api.github.com/repos/rvcevans/adventofcode/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/rvcevans/adventofcode/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rvcevans/adventofcode/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/rvcevans/adventofcode/statuses/46716837bd84bb463712fdc7fb86bb561b2b9d4c"}}}}
{"actor":{"display_login":"rvcevans"}}