-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Added support for environment variable SQUIRREL_TEMP to Setup.exe #846
Conversation
Allows to control where Setup.exe will extract and execute the package
Ready to merge @paulcbetts? |
return -1; | ||
} | ||
wchar_t *envSquirrelTemp = _wgetenv(L"SQUIRREL_TEMP"); | ||
if (envSquirrelTemp) { |
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.
We need to check that:
- This directory exists
- The user has write access to it
- It's not a UNC path
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.
Ok, I will add that too :)
Ok, I will add that too :) Think we should create folder if it doesn't exist? Or just skip using it? |
@paulcbetts: Added the stuff you asked for |
1. SQUIRREL_TEMP directory exists 2. The user has write access to it 3. It's not a UNC path
DeleteFile(szTempFileName); | ||
return true; | ||
} | ||
catch (...) { |
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.
What part of this operation could throw a C++ exception?
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.
GetTempFileNameW...
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.
I don't think that throws C++ exceptions, it's going to return an error code
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 is silly. Permissions could change after this is called, meaning you still have to deal with the failure in the action that proceeds this. Just do the action and skip this check.
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.
Calling my attempt to fix the issue with the missing environmentvariable for being silly isn't really constructive @riverar ! I'm trying to contribute since I first asked for a change and if this change isn't going to be made in due time we will simply have to throw squirrel down the drains since we simply can't use it...
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.
@LennartAJansson Oh I didn't mean that in a negative way. Poor choice of words on my part, in a repo that I've never commented in before. ☮️
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.
That's cool @riverar :) I haven't used C++ since the 90's and never contributed to anything on github either, working with ALM instead of coding nowadays
SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataDir); | ||
GetUserName(username, &unameSize); | ||
DWORD lastError = GetLastError(); | ||
if(!envSquirrelTempIsOk) { |
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.
Where do we actually use envSquirrelTemp
?
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.
_swprintf_c(targetDir, _countof(targetDir), L"%s", envSquirrelTemp);
Line 170
And if it's not set we will run the old way
envSquirrelTempIsOk was never set to true...
I found a copy and paste bug so envSquirrelTempIsOk was never set to true, sorry for that... Fixed it and pushed |
|
||
_swprintf_c(targetDir, _countof(targetDir), L"%s\\%s", appDataDir, username); | ||
SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataDir); |
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.
Deprecated API usage. Use SHGetKnownFolderPath instead. (You're not targeting XP users, right?)
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.
Didn't look at that part @riverar, that's old stuff :)
_swprintf_c(targetDir, _countof(targetDir), L"%s\\%s", appDataDir, username); | ||
SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataDir); | ||
GetUserName(username, &unameSize); | ||
DWORD lastError = GetLastError(); |
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.
Nit: lastError doesn't seem to be used here.
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.
@riverar: That part isn't mine either. I only focused on reading envvariable SQUIRREL_TEMP, it's supported in the managed part of squirrel but was missing in Setup...
@@ -177,3 +177,7 @@ nunit-Squirrel.Tests.xml | |||
|
|||
## Pester Test Output | |||
tests/Test.xml | |||
|
|||
## CPP db crap |
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.
Nit: Something a bit more professional would be:
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
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.
Agree on that, I shoudn't have pushed this change :)
Ok, I have removed the try - catch part, @paulcbetts |
Cool, sorry for being picky, we'll get this in today |
Awesome @paulcbetts Looks like we could do some more cleaning up in the future according to the comments from @riverar |
Fixed! |
Allows to control where Setup.exe will extract and execute the package
#843