You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/02/26 16:56:02 UTC

[maven-resolver] branch direct-write updated (7b4c074f -> f9de8896)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch direct-write
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git


 discard 7b4c074f Direct write
     new f9de8896 Direct write

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (7b4c074f)
            \
             N -- N -- N   refs/heads/direct-write (f9de8896)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[maven-resolver] 01/01: Direct write

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch direct-write
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit f9de8896af4c81fb82a8591ba2c9500e8a99b513
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Feb 26 17:55:41 2023 +0100

    Direct write
---
 .../org/eclipse/aether/internal/impl/DefaultFileProcessor.java   | 9 +++------
 .../eclipse/aether/internal/impl/DefaultTrackingFileManager.java | 9 ++++-----
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java
index 39028e99..44a76088 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultFileProcessor.java
@@ -35,7 +35,6 @@ import java.nio.file.StandardCopyOption;
 
 import org.eclipse.aether.spi.io.FileProcessor;
 import org.eclipse.aether.util.ChecksumUtils;
-import org.eclipse.aether.util.FileUtils;
 
 /**
  * A utility class helping with file-based operations.
@@ -77,11 +76,11 @@ public class DefaultFileProcessor implements FileProcessor {
     }
 
     public void write(File target, String data) throws IOException {
-        FileUtils.writeFile(target.toPath(), p -> Files.write(p, data.getBytes(StandardCharsets.UTF_8)));
+        Files.write(target.toPath(), data.getBytes(StandardCharsets.UTF_8));
     }
 
     public void write(File target, InputStream source) throws IOException {
-        FileUtils.writeFile(target.toPath(), p -> Files.copy(source, p, StandardCopyOption.REPLACE_EXISTING));
+        Files.copy(source, target.toPath(), StandardCopyOption.REPLACE_EXISTING);
     }
 
     public void copy(File source, File target) throws IOException {
@@ -90,10 +89,8 @@ public class DefaultFileProcessor implements FileProcessor {
 
     public long copy(File source, File target, ProgressListener listener) throws IOException {
         try (InputStream in = new BufferedInputStream(Files.newInputStream(source.toPath()));
-                FileUtils.CollocatedTempFile tempTarget = FileUtils.newTempFile(target.toPath());
-                OutputStream out = new BufferedOutputStream(Files.newOutputStream(tempTarget.getPath()))) {
+                OutputStream out = new BufferedOutputStream(Files.newOutputStream(target.toPath()))) {
             long result = copy(out, in, listener);
-            tempTarget.move();
             return result;
         }
     }
diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java
index 793ece14..80ea1062 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java
@@ -31,7 +31,6 @@ import java.nio.file.Path;
 import java.util.Map;
 import java.util.Properties;
 
-import org.eclipse.aether.util.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,7 +45,7 @@ public final class DefaultTrackingFileManager implements TrackingFileManager {
     @Override
     public Properties read(File file) {
         Path filePath = file.toPath();
-        if (Files.isRegularFile(filePath)) {
+        if (Files.isReadable(filePath)) {
             try (InputStream stream = Files.newInputStream(filePath)) {
                 Properties props = new Properties();
                 props.load(stream);
@@ -86,15 +85,15 @@ public final class DefaultTrackingFileManager implements TrackingFileManager {
                 }
             }
 
-            FileUtils.writeFile(filePath, p -> {
-                try (OutputStream stream = Files.newOutputStream(p)) {
+            if (Files.isWritable(filePath)) {
+                try (OutputStream stream = Files.newOutputStream(filePath)) {
                     LOGGER.debug("Writing tracking file '{}'", file);
                     props.store(
                             stream,
                             "NOTE: This is a Maven Resolver internal implementation file"
                                     + ", its format can be changed without prior notice.");
                 }
-            });
+            }
         } catch (IOException e) {
             LOGGER.warn("Failed to write tracking file '{}'", file, e);
             throw new UncheckedIOException(e);