{"action":"created","comment":{"url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/comments/83113336","pull_request_review_id":3975865,"id":83113336,"diff_hunk":"@@ -137,31 +161,46 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine, bool useFallback\n \twchar_t logFile[MAX_PATH];\n \tstd::vector<CString> to_delete;\n \n-\tif (!useFallbackDir) {\n-\t\tSHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, targetDir);\n-\t} else {\n-\t\twchar_t username[512];\n-\t\twchar_t uid[128];\n-\t\twchar_t appDataDir[MAX_PATH];\n-\t\tULONG unameSize = _countof(username);\n+\tbool envSquirrelTempIsOk = false;\n+\twchar_t *envSquirrelTemp = _wgetenv(L\"SQUIRREL_TEMP\");\n+\tif (envSquirrelTemp) {\n+\t\tif (DirectoryExistsW(envSquirrelTemp)) {\n+\t\t\tif (DirectoryIsWritableW(envSquirrelTemp)) {\n+\t\t\t\tif (!PathIsUNCW(envSquirrelTemp)) {\n+\t\t\t\t\t_swprintf_c(targetDir, _countof(targetDir), L\"%s\", envSquirrelTemp);\n+\t\t\t\t\tbool envSquirrelTempIsOk = false;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t}\n \n-\t\tSHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataDir);\n-\t\tGetUserName(username, &unameSize);\n-\t\tDWORD lastError = GetLastError();\n+\tif(!envSquirrelTempIsOk) {\n+\t\tif (!useFallbackDir) {\n+\t\t\tSHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, targetDir);\n+\t\t} else {\n+\t\t\twchar_t username[512];\n+\t\t\twchar_t uid[128];\n+\t\t\twchar_t appDataDir[MAX_PATH];\n+\t\t\tULONG unameSize = _countof(username);\n \n-\t\t_swprintf_c(targetDir, _countof(targetDir), L\"%s\\\\%s\", appDataDir, username);\n+\t\t\tSHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataDir);\n+\t\t\tGetUserName(username, &unameSize);\n+\t\t\tDWORD lastError = GetLastError();","path":"src/Setup/UpdateRunner.cpp","position":70,"original_position":70,"commit_id":"8dd3e9aab00ef3ecb979947b2369f0f0158ba1bc","original_commit_id":"62941f88667a2dceecdff300f72d41f83de99343","user":{"login":"riverar","id":475132,"avatar_url":"https://avatars.githubusercontent.com/u/475132?v=3","gravatar_id":"","url":"https://api.github.com/users/riverar","html_url":"https://github.com/riverar","followers_url":"https://api.github.com/users/riverar/followers","following_url":"https://api.github.com/users/riverar/following{/other_user}","gists_url":"https://api.github.com/users/riverar/gists{/gist_id}","starred_url":"https://api.github.com/users/riverar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riverar/subscriptions","organizations_url":"https://api.github.com/users/riverar/orgs","repos_url":"https://api.github.com/users/riverar/repos","events_url":"https://api.github.com/users/riverar/events{/privacy}","received_events_url":"https://api.github.com/users/riverar/received_events","type":"User","site_admin":false},"body":"Nit: lastError doesn't seem to be used here.","created_at":"2016-10-12T22:34:41Z","updated_at":"2016-10-12T22:34:41Z","html_url":"https://github.com/Squirrel/Squirrel.Windows/pull/846#discussion_r83113336","pull_request_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846","_links":{"self":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/comments/83113336"},"html":{"href":"https://github.com/Squirrel/Squirrel.Windows/pull/846#discussion_r83113336"},"pull_request":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846"}}},"pull_request":{"url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846","id":88057316,"html_url":"https://github.com/Squirrel/Squirrel.Windows/pull/846","diff_url":"https://github.com/Squirrel/Squirrel.Windows/pull/846.diff","patch_url":"https://github.com/Squirrel/Squirrel.Windows/pull/846.patch","issue_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/issues/846","number":846,"state":"open","locked":false,"title":"Added support for environment variable SQUIRREL_TEMP to Setup.exe","user":{"login":"LennartAJansson","id":16935455,"avatar_url":"https://avatars.githubusercontent.com/u/16935455?v=3","gravatar_id":"","url":"https://api.github.com/users/LennartAJansson","html_url":"https://github.com/LennartAJansson","followers_url":"https://api.github.com/users/LennartAJansson/followers","following_url":"https://api.github.com/users/LennartAJansson/following{/other_user}","gists_url":"https://api.github.com/users/LennartAJansson/gists{/gist_id}","starred_url":"https://api.github.com/users/LennartAJansson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LennartAJansson/subscriptions","organizations_url":"https://api.github.com/users/LennartAJansson/orgs","repos_url":"https://api.github.com/users/LennartAJansson/repos","events_url":"https://api.github.com/users/LennartAJansson/events{/privacy}","received_events_url":"https://api.github.com/users/LennartAJansson/received_events","type":"User","site_admin":false},"body":"Allows to control where Setup.exe will extract and execute the package\r\n\r\n#843 ","created_at":"2016-10-05T11:05:36Z","updated_at":"2016-10-12T22:34:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f1e4b74e0428d37ddf339c01dc35c5de96fac239","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846/commits","review_comments_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846/comments","review_comment_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/issues/846/comments","statuses_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/statuses/8dd3e9aab00ef3ecb979947b2369f0f0158ba1bc","head":{"label":"LennartAJansson:master","ref":"master","sha":"8dd3e9aab00ef3ecb979947b2369f0f0158ba1bc","user":{"login":"LennartAJansson","id":16935455,"avatar_url":"https://avatars.githubusercontent.com/u/16935455?v=3","gravatar_id":"","url":"https://api.github.com/users/LennartAJansson","html_url":"https://github.com/LennartAJansson","followers_url":"https://api.github.com/users/LennartAJansson/followers","following_url":"https://api.github.com/users/LennartAJansson/following{/other_user}","gists_url":"https://api.github.com/users/LennartAJansson/gists{/gist_id}","starred_url":"https://api.github.com/users/LennartAJansson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LennartAJansson/subscriptions","organizations_url":"https://api.github.com/users/LennartAJansson/orgs","repos_url":"https://api.github.com/users/LennartAJansson/repos","events_url":"https://api.github.com/users/LennartAJansson/events{/privacy}","received_events_url":"https://api.github.com/users/LennartAJansson/received_events","type":"User","site_admin":false},"repo":{"id":70052175,"name":"Squirrel.Windows","full_name":"LennartAJansson/Squirrel.Windows","owner":{"login":"LennartAJansson","id":16935455,"avatar_url":"https://avatars.githubusercontent.com/u/16935455?v=3","gravatar_id":"","url":"https://api.github.com/users/LennartAJansson","html_url":"https://github.com/LennartAJansson","followers_url":"https://api.github.com/users/LennartAJansson/followers","following_url":"https://api.github.com/users/LennartAJansson/following{/other_user}","gists_url":"https://api.github.com/users/LennartAJansson/gists{/gist_id}","starred_url":"https://api.github.com/users/LennartAJansson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LennartAJansson/subscriptions","organizations_url":"https://api.github.com/users/LennartAJansson/orgs","repos_url":"https://api.github.com/users/LennartAJansson/repos","events_url":"https://api.github.com/users/LennartAJansson/events{/privacy}","received_events_url":"https://api.github.com/users/LennartAJansson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LennartAJansson/Squirrel.Windows","description":"An installation and update framework for Windows desktop apps","fork":true,"url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows","forks_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/forks","keys_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/teams","hooks_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/hooks","issue_events_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/issues/events{/number}","events_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/events","assignees_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/assignees{/user}","branches_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/branches{/branch}","tags_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/tags","blobs_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/git/refs{/sha}","trees_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/statuses/{sha}","languages_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/languages","stargazers_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/stargazers","contributors_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/contributors","subscribers_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/subscribers","subscription_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/subscription","commits_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/commits{/sha}","git_commits_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/git/commits{/sha}","comments_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/comments{/number}","issue_comment_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/issues/comments{/number}","contents_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/contents/{+path}","compare_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/merges","archive_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/downloads","issues_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/issues{/number}","pulls_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/pulls{/number}","milestones_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/milestones{/number}","notifications_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/labels{/name}","releases_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/releases{/id}","deployments_url":"https://api.github.com/repos/LennartAJansson/Squirrel.Windows/deployments","created_at":"2016-10-05T10:57:38Z","updated_at":"2016-10-05T10:57:40Z","pushed_at":"2016-10-12T14:03:56Z","git_url":"git://github.com/LennartAJansson/Squirrel.Windows.git","ssh_url":"git@github.com:LennartAJansson/Squirrel.Windows.git","clone_url":"https://github.com/LennartAJansson/Squirrel.Windows.git","svn_url":"https://github.com/LennartAJansson/Squirrel.Windows","homepage":"","size":81614,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"Squirrel:master","ref":"master","sha":"6722c66f776c93d83cc35cd7b79ccab676eb7b2b","user":{"login":"Squirrel","id":5743792,"avatar_url":"https://avatars.githubusercontent.com/u/5743792?v=3","gravatar_id":"","url":"https://api.github.com/users/Squirrel","html_url":"https://github.com/Squirrel","followers_url":"https://api.github.com/users/Squirrel/followers","following_url":"https://api.github.com/users/Squirrel/following{/other_user}","gists_url":"https://api.github.com/users/Squirrel/gists{/gist_id}","starred_url":"https://api.github.com/users/Squirrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squirrel/subscriptions","organizations_url":"https://api.github.com/users/Squirrel/orgs","repos_url":"https://api.github.com/users/Squirrel/repos","events_url":"https://api.github.com/users/Squirrel/events{/privacy}","received_events_url":"https://api.github.com/users/Squirrel/received_events","type":"Organization","site_admin":false},"repo":{"id":22338518,"name":"Squirrel.Windows","full_name":"Squirrel/Squirrel.Windows","owner":{"login":"Squirrel","id":5743792,"avatar_url":"https://avatars.githubusercontent.com/u/5743792?v=3","gravatar_id":"","url":"https://api.github.com/users/Squirrel","html_url":"https://github.com/Squirrel","followers_url":"https://api.github.com/users/Squirrel/followers","following_url":"https://api.github.com/users/Squirrel/following{/other_user}","gists_url":"https://api.github.com/users/Squirrel/gists{/gist_id}","starred_url":"https://api.github.com/users/Squirrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Squirrel/subscriptions","organizations_url":"https://api.github.com/users/Squirrel/orgs","repos_url":"https://api.github.com/users/Squirrel/repos","events_url":"https://api.github.com/users/Squirrel/events{/privacy}","received_events_url":"https://api.github.com/users/Squirrel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Squirrel/Squirrel.Windows","description":"An installation and update framework for Windows desktop apps","fork":false,"url":"https://api.github.com/repos/Squirrel/Squirrel.Windows","forks_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/forks","keys_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/teams","hooks_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/hooks","issue_events_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/issues/events{/number}","events_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/events","assignees_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/assignees{/user}","branches_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/branches{/branch}","tags_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/tags","blobs_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/git/refs{/sha}","trees_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/statuses/{sha}","languages_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/languages","stargazers_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/stargazers","contributors_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/contributors","subscribers_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/subscribers","subscription_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/subscription","commits_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/commits{/sha}","git_commits_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/git/commits{/sha}","comments_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/comments{/number}","issue_comment_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/issues/comments{/number}","contents_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/contents/{+path}","compare_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/merges","archive_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/downloads","issues_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/issues{/number}","pulls_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls{/number}","milestones_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/milestones{/number}","notifications_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/labels{/name}","releases_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/releases{/id}","deployments_url":"https://api.github.com/repos/Squirrel/Squirrel.Windows/deployments","created_at":"2014-07-28T10:10:39Z","updated_at":"2016-10-12T21:05:00Z","pushed_at":"2016-10-12T14:03:57Z","git_url":"git://github.com/Squirrel/Squirrel.Windows.git","ssh_url":"git@github.com:Squirrel/Squirrel.Windows.git","clone_url":"https://github.com/Squirrel/Squirrel.Windows.git","svn_url":"https://github.com/Squirrel/Squirrel.Windows","homepage":"","size":82190,"stargazers_count":2282,"watchers_count":2282,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":320,"mirror_url":null,"open_issues_count":259,"forks":320,"open_issues":259,"watchers":2282,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846"},"html":{"href":"https://github.com/Squirrel/Squirrel.Windows/pull/846"},"issue":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/issues/846"},"comments":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/issues/846/comments"},"review_comments":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846/comments"},"review_comment":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/pulls/846/commits"},"statuses":{"href":"https://api.github.com/repos/Squirrel/Squirrel.Windows/statuses/8dd3e9aab00ef3ecb979947b2369f0f0158ba1bc"}}}}
{"actor":{"display_login":"riverar"}}