-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Filesystem/Win32: Recreate hardlinks on fs::pending_file #16256
Conversation
8f58b56
to
a3ff474
Compare
Utilities/File.cpp
Outdated
@@ -2486,16 +2485,62 @@ bool fs::pending_file::commit(bool overwrite) | |||
disp.DeleteFileW = false; | |||
ensure(SetFileInformationByHandle(file.get_handle(), FileDispositionInfo, &disp, sizeof(disp))); | |||
} | |||
|
|||
std::vector<std::wstring> hardlinkPaths; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scnakecase
Utilities/File.cpp
Outdated
|
||
const auto ws1 = to_wchar(m_path); | ||
|
||
const HANDLE fileHandle = CreateFileW(ws1.get(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snakecase
Utilities/File.cpp
Outdated
while (fileHandle != INVALID_HANDLE_VALUE) | ||
{ | ||
// Get file ID (used to check for hardlinks) | ||
BY_HANDLE_FILE_INFORMATION fileInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snakecase
Utilities/File.cpp
Outdated
|
||
// Buffer for holding link name | ||
WCHAR linkNameBuffer[MAX_PATH]; | ||
HANDLE findHandle = FindFirstFileNameW(ws1.get(), 0, nullptr, linkNameBuffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things:
-Limiting to MAX_PATH on windows has been a problem in the past if I recall, we should avoid that if possible
-Is nullptr for StringLength even valid, documentation doesn't mention it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
307c02c
to
a896624
Compare
maybe the fix for #16245 (reported in that PR) could be also provided in this PR |
Utilities/File.cpp
Outdated
while (true) | ||
{ | ||
buffer_size = link_name_buffer.size() - 1; | ||
findHandle = FindFirstFileNameW(ws1.get(), 0, &buffer_size, link_name_buffer.data()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findHandle = FindFirstFileNameW(ws1.get(), 0, &buffer_size, link_name_buffer.data()); | |
find_handle = FindFirstFileNameW(ws1.get(), 0, &buffer_size, link_name_buffer.data()); |
411b52d
to
db4a7ca
Compare
fd8df8d
to
cca8138
Compare
4808c47
to
0b7a9f8
Compare
Attempting to address #16255
Also fixes #16260