-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: util/path: CheckSystemDriveAndRemoveDriveLetter
to preserve /
#5317
Open
profnandaa
wants to merge
1
commit into
moby:master
Choose a base branch
from
profnandaa:fix-5249-copy-dir-path
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−2
Conversation
This file contains 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
profnandaa
changed the title
fix: util/path: CheckSystemDriveAndRemoveDriveLetter to preserve
fix: util/path: Sep 10, 2024
/
CheckSystemDriveAndRemoveDriveLetter
to preserve /
Looking into the CI failures... |
Found the regression caused by this, thankfully coz of the checked in integration tests! Dockerfile: FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
COPY test1.txt /sample/
RUN type \sample\test1.txt
COPY test1.txt /
COPY test1.txt /test2.txt
RUN type test1.txt
RUN type test2.txt Build log:
Fixing. |
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
4 times, most recently
from
September 11, 2024 08:00
ac8552f
to
af77ee9
Compare
tonistiigi
reviewed
Sep 11, 2024
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
from
September 12, 2024 04:24
af77ee9
to
be65686
Compare
tonistiigi
reviewed
Sep 12, 2024
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
3 times, most recently
from
September 13, 2024 08:21
36e398e
to
1a5289c
Compare
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
from
September 17, 2024 09:19
1a5289c
to
c55dbc3
Compare
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
from
September 17, 2024 09:19
c55dbc3
to
288b5db
Compare
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
from
September 24, 2024 07:46
288b5db
to
c91001c
Compare
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
2 times, most recently
from
September 24, 2024 08:27
aca0ccb
to
e8ae74c
Compare
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
2 times, most recently
from
September 25, 2024 04:02
54b0fbd
to
4056da0
Compare
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
from
September 25, 2024 05:13
4056da0
to
b4437dc
Compare
CI failure seems unrelated?
|
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
from
September 26, 2024 15:18
b4437dc
to
31e2d43
Compare
PTAL again, addressed the comments. @tonistiigi @gabriel-samfira |
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
5 times, most recently
from
October 9, 2024 04:31
5dd50bb
to
2d75bcd
Compare
The call to CheckSystemDriveAndRemoveDriveLetter() does not preserve the trailing `/` or `\\`. This happens because `filepath.Clean()` strips away any trailing slashes. For example `/sample/` will be `\\sample` on Windows and `/sample` on Linux. This function was mainly written for Windows scenarios, which have System Drive Letters like C:/, etc. This was causing cases like `COPY testfile /testdir/` to be intepreted as `COPY testfile /testdir`, and if `testdir` is not explictly created before the call, it ends up being treated as a destination file other than a directory. Fix this by checking that if we have a trailing `/` or `\\`, we preserve it after the call to `filepath.Clean()`. Fixes moby#5249 PS. Also fixed for cross-building from Linux scenario, taking care for paths like `\\sample\\` that are not changed when run through `filepath.Clean()`. Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
profnandaa
force-pushed
the
fix-5249-copy-dir-path
branch
from
October 9, 2024 09:11
2d75bcd
to
1dc5d2b
Compare
gabriel-samfira
approved these changes
Oct 9, 2024
LGTM. Waiting for a second review before merging. |
Thanks!
…On Wed, Oct 9, 2024, 12:28 Gabriel ***@***.***> wrote:
LGTM. Waiting for a second review before merging.
—
Reply to this email directly, view it on GitHub
<#5317 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB7ZEMYKEKKZE5GDTAXVQLZ2TZKPAVCNFSM6AAAAABN6FHHEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBRHAYDSOBYGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@crazy-max @tonistiigi -- can take a look at this one? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The call to CheckSystemDriveAndRemoveDriveLetter() does not preserve the trailing
/
or\\
. This happens becausefilepath.Clean()
strips away any trailing slashes. For example/sample/
will be\\sample
on Windows. This function was mainly written for Windows scenarios, which have System Drive Letters like C:/, etc.This was causing cases like
COPY testfile /testdir/
to be intepreted asCOPY testfile /testdir
, and iftestdir
is not explictly created before the call, it ends up being treated as a destination file other than a directory.Fix this by checking that if we have a trailing
/
or\\
, we preserve it after the call tofilepath.Clean()
.Fixes #5249
PS.
Also fixed for cross-building Windows from Linux, that would fail silently:
Repro dockerfile without
RUN
:Build log:
Checking results,
sample
is a file instead of a directory:NOTE: also covered cases like, where platform-specific
filepath.Clean()
won't strip out the\\
on Linux: