Skip to content

Commit

Permalink
Improved handling of normal alias update cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Feb 28, 2024
1 parent e260809 commit a6e8f18
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions PC/launcher2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2725,13 +2725,33 @@ manageAlias(int activate, const SearchInfo *search, const EnvironmentInfo *launc
}

if (activate) {
int skip = dryRun;
debug(L"# Creating alias at '%s'\n", aliasExe);
if (!dryRun && useHardLink) {
if (!skip) {
if (!DeleteFileW(aliasExe)) {
switch (GetLastError()) {
case ERROR_FILE_NOT_FOUND:
// Best result - file didn't exist
break;
case ERROR_ACCESS_DENIED:
// File exists but we can't touch it.
debug(L"Failed to remove existing alias '%s'\n", aliasExe);
skip = 1;
break;
default:
// Some other reason we can't create aliases here
winerror(0, L"Failed to remove existing alias '%s'", aliasExe);
skip = 1;
break;
}
}
}
if (!skip && useHardLink) {
if (!CreateHardLinkW(aliasExe, pyExe, NULL)) {
useHardLink = 0;
}
}
if (!dryRun && !useHardLink) {
if (!skip && !useHardLink) {
if (!CopyFileW(pyExe, aliasExe, FALSE)) {
winerror(0, L"Failed to create alias '%s'", aliasExe);
exitCode = RC_NO_ALIAS;
Expand Down

0 comments on commit a6e8f18

Please sign in to comment.