Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WriteUTF8FileAtomic to preserve symlinks #10908

Merged
6 commits merged into from
Aug 12, 2021
Merged
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/cascadia/TerminalSettingsModel/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ namespace Microsoft::Terminal::Settings::Model
{
// GH#10787: In the case of symbolic link, ensure that we modify the target rather than the link itself.
// We append the paths manually rather than using "canonical" method to support scenario in which link target doesn't exist
const auto resolvedPath = std::filesystem::is_symlink(path) ? path.parent_path() / std::filesystem::read_symlink(path) : path;
auto resolvedPath = path;
while (std::filesystem::is_symlink(resolvedPath))
{
resolvedPath = resolvedPath.parent_path() / std::filesystem::read_symlink(resolvedPath);
}
Don-Vito marked this conversation as resolved.
Show resolved Hide resolved

auto tmpPath = resolvedPath;
tmpPath += L".tmp";
Expand Down