Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/AppInstallerSharedLib/Filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
1 change: 0 additions & 1 deletion src/AppInstallerSharedLib/Public/winget/Filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading