Squirrel / Squirrel.Mac

:shipit: Cocoa framework for updating OS X apps :shipit:
MIT License
1.59k stars 128 forks source link

fix: Ensure we use a writable log file. #255

Closed devinfoley closed 3 years ago

devinfoley commented 4 years ago

Squirrel.mac has an issue wherein if ShipIt_stderr.log or ShipIt_stdout.log aren't writable, ShipIt will fail to launch. If the entire ShipIt directory isn't writable, we detect that and prompt the user for credentials, but if the directory is writable and the log files contained are not, we just die silently.

This PR changes the logic used the generate the log file URLs so that we always generate writable log file URLs. Before returning the log file URL, we test to see if it's writable. If not, we append a number to the URL and test that URL. We repeat this process until we find a writable log file URL, or we reach 100 and give up.

I also included a little code cleanup to reduce duplication, so that this new logic doesn't get copied all over the place.

devinfoley commented 3 years ago

@MarshallOfSound good call. Added!