Skip to content

pkg/atomicwriter: New(): prevent creating temp-file on errors, and use absolute paths#49607

Merged
vvoland merged 2 commits intomoby:masterfrom
thaJeztah:atomicwriter_enhance
Mar 10, 2025
Merged

pkg/atomicwriter: New(): prevent creating temp-file on errors, and use absolute paths#49607
vvoland merged 2 commits intomoby:masterfrom
thaJeztah:atomicwriter_enhance

Conversation

@thaJeztah
Copy link
Member

pkg/atomicwriter: New(): prevent creating temp-file on errors

The temp-file was created before trying to make the given filename an
absolute path. Reverse the order of code so that we don't create
a temp-file if an error happens.

pkg/atomicwriter: New(): use absolute path for temp-file

Use an absolute path for both the temp-file and the destination-file.

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

The temp-file was created before trying to make the given filename an
absolute path. Reverse the order of code so that we don't create
a temp-file if an error happens.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use an absolute path for both the temp-file and the destination-file.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Mar 9, 2025
@vvoland vvoland added this to the 28.0.2 milestone Mar 10, 2025
@vvoland vvoland merged commit c3c3eb2 into moby:master Mar 10, 2025
155 checks passed
@thaJeztah thaJeztah deleted the atomicwriter_enhance branch March 10, 2025 13:03
@thaJeztah
Copy link
Member Author

Thx! I have a bunch of updates after this; after testing some scenarios with this package, there were some fun corner-cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants