Skip to content
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

FileUtils.copyFile in 3.1.0 fails on second invocation if Windows read-only flag is set on the source file #38

Open
awallgren opened this issue Apr 8, 2018 · 1 comment

Comments

@awallgren
Copy link

FileUtils.copyFile was changed to use the NIO Files.copy call a while back. Files.copy is invoked with the COPY_ATTRIBUTES and REPLACE_EXISTING attributes (which makes sense).

However, on Windows, COPY_ATTRIBUTES preserves the read-only flag if it's set on the source file, BUT REPLACE_EXISTING fails with an AccessDeniedException exception if the destinations' read-only attribute is set.

This is problematic because it breaks existing builds when updating from maven-war-plugin:3.1.0 to maven-war-plugin-3.2.0 (which switch from plexus-utils-3.0.24 to plexus-utils-3.1.0) where the SCM uses the read-only flag for unmodified files, e.g. Perforce.

TBH, I'm not sure where I come down on whether this is a bug in the JDK (REPLACE_EXISTING doesn't) or plexus-utils (using COPY_ATTRIBUTES may include attributes that make subsequent invocations with REPLACE_EXISTING to fail in a platform-specific way).

@awallgren awallgren changed the title FileUtils.copyFile fails on second invocation if Windows read-only flag is set on the source file FileUtils.copyFile in 3.1.0 fails on second invocation if Windows read-only flag is set on the source file Apr 8, 2018
awallgren added a commit to awallgren/plexus-utils that referenced this issue Apr 8, 2018
awallgren added a commit to awallgren/plexus-utils that referenced this issue Apr 8, 2018
@michael-o michael-o modified the milestone: 3.2.0 May 22, 2018
@michael-o
Copy link
Member

Have you actually tried that on Unix? Does it fail too?

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

No branches or pull requests

2 participants