-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Switch to hardlink for retry if rename does not succeed #1496
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
32ccafc
Merge pull request #1 from microsoft/master
sreadingMSFT ef00fb8
Merge pull request #3 from ashpatil-msft/master
sreadingMSFT da6aa19
Merge pull request #5 from microsoft/master
sreadingMSFT bad3b48
Merge branch 'microsoft:master' into master
sreadingMSFT 105a7f5
Merge branch 'microsoft:master' into master
sreadingMSFT a0ebabb
Merge branch 'microsoft:master' into master
sreadingMSFT 906e4c9
Merge branch 'microsoft:master' into master
sreadingMSFT 4d20d75
Merge branch 'microsoft:master' into master
sreadingMSFT 6089827
Merge branch 'microsoft:master' into master
sreadingMSFT 9d89ba0
Merge branch 'microsoft:master' into master
sreadingMSFT f2f5f7d
Merge branch 'microsoft:master' into master
sreadingMSFT 9d47650
Merge branch 'microsoft:master' into master
sreadingMSFT bd772cd
Merge branch 'microsoft:master' into master
sreadingMSFT 8c0f2b3
Merge branch 'microsoft:master' into master
sreadingMSFT 45de657
Switch to file copy instead of rename.
sreadingMSFT d97b3ff
fix spelling
sreadingMSFT 10a943a
Merge branch 'master' of https://github.com/microsoft/winget-cli into…
sreadingMSFT 3e5e035
Merge branch 'microsoft-master' into copyFileRetry
sreadingMSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,7 @@ getline | |
| github | ||
| githubusercontent | ||
| globals | ||
| hardlink | ||
| hfile | ||
| HGLOBAL | ||
| HIDECANCEL | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,8 +256,9 @@ namespace AppInstaller::CLI::Workflow | |
| if (retry) | ||
| { | ||
| std::this_thread::sleep_for(250ms); | ||
| // If it fails again, let that one throw | ||
| std::filesystem::rename(installerPath, renamedDownloadedInstaller); | ||
| // If retry fails, try copying with hardlink. The file at installerPath will not be cleaned up after installation, | ||
| // but it is in a temp folder. | ||
| std::filesystem::copy(installerPath, renamedDownloadedInstaller, std::filesystem::copy_options::create_hard_links); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking to make it retry every 100ms for 500ms, and only then copy. Since the file won't get cleaned up we would really prefer the rename.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. |
||
| } | ||
|
|
||
| installerPath.assign(renamedDownloadedInstaller); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
if rename fails?