From 738e6445facea8a71d255731dcf7a13e4b1d09ea Mon Sep 17 00:00:00 2001 From: Rich Purnell Date: Sun, 7 Jun 2026 02:39:09 +0800 Subject: [PATCH 1/2] Remove invalid CreateSymlink overload declaration --- src/AppInstallerSharedLib/Public/winget/Filesystem.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AppInstallerSharedLib/Public/winget/Filesystem.h b/src/AppInstallerSharedLib/Public/winget/Filesystem.h index 1a7df6aa28..ba4b5cf7bc 100644 --- a/src/AppInstallerSharedLib/Public/winget/Filesystem.h +++ b/src/AppInstallerSharedLib/Public/winget/Filesystem.h @@ -38,7 +38,6 @@ namespace AppInstaller::Filesystem // Checks if the path is a symlink and exists. bool SymlinkExists(const std::filesystem::path& symlinkPath); - bool CreateSymlink(const std::filesystem::path& path, const std::filesystem::path& target); // Get expanded file system path. std::filesystem::path GetExpandedPath(const std::string& path); From 2f8b7f5b7c9c947e9df561cd7a500cae570a0e63 Mon Sep 17 00:00:00 2001 From: Rich Purnell Date: Sun, 7 Jun 2026 03:33:00 +0800 Subject: [PATCH 2/2] Fall back to hard link when symlink creation lacks privilege --- src/AppInstallerSharedLib/Filesystem.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/AppInstallerSharedLib/Filesystem.cpp b/src/AppInstallerSharedLib/Filesystem.cpp index 2e0e283359..08b6f21315 100644 --- a/src/AppInstallerSharedLib/Filesystem.cpp +++ b/src/AppInstallerSharedLib/Filesystem.cpp @@ -465,7 +465,17 @@ namespace AppInstaller::Filesystem { if (error.code().value() == ERROR_PRIVILEGE_NOT_HELD) { - return false; + // If symlink creation fails due to insufficient privileges, + // fall back to creating a hard link instead. + try + { + std::filesystem::create_hard_link(target, link); + return true; + } + catch (...) + { + return false; + } } else {