Skip to content
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

Merged
merged 5 commits into from
Oct 17, 2016
Merged

Added support for environment variable SQUIRREL_TEMP to Setup.exe #846

merged 5 commits into from
Oct 17, 2016

Conversation

LennartAJansson
Copy link
Contributor

Allows to control where Setup.exe will extract and execute the package
#843

Allows to control where Setup.exe will extract and execute the package
@LennartAJansson
Copy link
Contributor Author

Ready to merge @paulcbetts?

return -1;
}
wchar_t *envSquirrelTemp = _wgetenv(L"SQUIRREL_TEMP");
if (envSquirrelTemp) {
Copy link
Contributor

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:

  1. This directory exists
  2. The user has write access to it
  3. It's not a UNC path

Copy link
Contributor Author

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 :)

@LennartAJansson
Copy link
Contributor Author

Ok, I will add that too :) Think we should create folder if it doesn't exist? Or just skip using it?

@LennartAJansson
Copy link
Contributor Author

@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 (...) {
Copy link
Contributor

@anaisbetts anaisbetts Oct 11, 2016

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetTempFileNameW...

Copy link
Contributor

@anaisbetts anaisbetts Oct 12, 2016

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

Copy link

@riverar riverar Oct 12, 2016

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.

Copy link
Contributor Author

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...

Copy link

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. ☮️

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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...
@LennartAJansson
Copy link
Contributor Author

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);
Copy link

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?)

Copy link
Contributor Author

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();
Copy link

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.

Copy link
Contributor Author

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
Copy link

@riverar riverar Oct 12, 2016

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

Copy link
Contributor Author

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 :)

@LennartAJansson
Copy link
Contributor Author

Ok, I have removed the try - catch part, @paulcbetts

@anaisbetts
Copy link
Contributor

Cool, sorry for being picky, we'll get this in today

@LennartAJansson
Copy link
Contributor Author

Awesome @paulcbetts Looks like we could do some more cleaning up in the future according to the comments from @riverar

@anaisbetts anaisbetts merged commit 63f215e into Squirrel:master Oct 17, 2016
@anaisbetts
Copy link
Contributor

Fixed!

@Thieum Thieum mentioned this pull request May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants