Skip to content
Merged
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
13 changes: 11 additions & 2 deletions src/AppInstallerCLICore/PortableInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,18 @@ namespace AppInstaller::CLI::Portable
if (!targetFullPath.empty() && targetFullPath.filename() != symlinkFullPath.filename())
{
std::filesystem::path hardlinkPath = InstallLocation / symlinkFullPath.filename();
if (hardlinkPath != targetFullPath && std::filesystem::exists(hardlinkPath))

// The symlink can live in the install location, in which case it is not a hardlink alias.
if (hardlinkPath != targetFullPath && hardlinkPath != symlinkFullPath)
{
m_expectedEntries.emplace_back(PortableFileEntry::CreateHardlinkEntry(hardlinkPath, targetFullPath, SHA256));
// Use symlink_status so that the path is not traversed; a hardlink alias is always a regular file.
std::error_code hardlinkStatusError;
std::filesystem::file_status hardlinkStatus = std::filesystem::symlink_status(hardlinkPath, hardlinkStatusError);

if (!hardlinkStatusError && std::filesystem::is_regular_file(hardlinkStatus))
{
m_expectedEntries.emplace_back(PortableFileEntry::CreateHardlinkEntry(hardlinkPath, targetFullPath, SHA256));
}
}
}
m_expectedEntries.emplace_back(PortableFileEntry::CreateSymlinkEntry(symlinkFullPath, targetFullPath));
Expand Down
Loading