Skip to content

os: avoid creating a new file in Truncate on Windows #59085

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

Conversation

nwnt
Copy link
Contributor

@nwnt nwnt commented Mar 17, 2023

Truncate() a non existent file on Windows currently creates a new blank
file. This behavior is not consistent with other OSes where a file not
found error would instead be returned. This change makes Truncate on
Windows return a file-not-found error when the specified file doesn't
exist, bringing the behavior consistent.

New test cases have been added to prevent a regression.

Fixes #58977

@nwnt nwnt changed the title os: Truncate on Windows will not create a new file os: truncate on Windows will not create a new file Mar 17, 2023
@gopherbot
Copy link
Contributor

This PR (HEAD: 2f22f43) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/477215 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Quim Muntal:

Patch Set 1: Run-TryBot+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Quim Muntal:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan Mills:

Patch Set 1: Code-Review+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@nwnt nwnt force-pushed the os-truncate-windows-no-new-file-created branch from 2f22f43 to 9600f6c Compare March 20, 2023 06:25
@gopherbot
Copy link
Contributor

This PR (HEAD: 9600f6c) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/477215 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Thanonchai W:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@nwnt nwnt force-pushed the os-truncate-windows-no-new-file-created branch from 9600f6c to b7b06e0 Compare March 20, 2023 16:00
@gopherbot
Copy link
Contributor

This PR (HEAD: b7b06e0) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/477215 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Thanonchai W:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan Mills:

Patch Set 2: Code-Review+1

(5 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@nwnt nwnt changed the title os: truncate on Windows will not create a new file os: avoid creating a new file in Truncate on Windows Mar 21, 2023
@nwnt nwnt force-pushed the os-truncate-windows-no-new-file-created branch from b7b06e0 to a95af92 Compare March 21, 2023 05:45
@gopherbot
Copy link
Contributor

This PR (HEAD: a95af92) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/477215 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Thanonchai W:

Patch Set 3:

(6 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

Copy link

@maxwelbm maxwelbm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 5: Auto-Submit+1 Code-Review+2 Run-TryBot+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan Mills:

Patch Set 5: Code-Review+1

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 5: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

Truncate() a non existent file on Windows currently creates a new blank
file. This behavior is not consistent with other OSes where a file not
found error would instead be returned. This change makes Truncate on
Windows return a file-not-found error when the specified file doesn't
exist, bringing the behavior consistent.

New test cases have been added to prevent a regression.

Fixes 58977
@nwnt nwnt force-pushed the os-truncate-windows-no-new-file-created branch from a95af92 to 636b6c3 Compare March 22, 2023 01:02
@gopherbot
Copy link
Contributor

This PR (HEAD: 636b6c3) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/477215 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Thanonchai W:

Patch Set 6:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Quim Muntal:

Patch Set 6: Code-Review+2 Run-TryBot+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 6:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 6: TryBot-Result+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/477215.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Mar 22, 2023
Truncate() a non existent file on Windows currently creates a new blank
file. This behavior is not consistent with other OSes where a file not
found error would instead be returned. This change makes Truncate on
Windows return a file-not-found error when the specified file doesn't
exist, bringing the behavior consistent.

New test cases have been added to prevent a regression.

Fixes #58977

Change-Id: Iaf7b41fc4ea86a2b2ccc59f8be81be42ed211b5c
GitHub-Last-Rev: 636b6c3
GitHub-Pull-Request: #59085
Reviewed-on: https://go-review.googlesource.com/c/go/+/477215
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Quim Muntal <[email protected]>
Run-TryBot: Quim Muntal <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/477215 has been merged.

@gopherbot gopherbot closed this Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

os: Truncate() on a non-existent file will create a file on Windows
3 participants