summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit/.settings/.api_filters2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java12
3 files changed, 11 insertions, 5 deletions
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
index d313e92a05..5f58e7e457 100644
--- a/org.eclipse.jgit/.settings/.api_filters
+++ b/org.eclipse.jgit/.settings/.api_filters
@@ -153,7 +153,7 @@
<resource path="src/org/eclipse/jgit/util/FileUtils.java" type="org.eclipse.jgit.util.FileUtils">
<filter id="1142947843">
<message_arguments>
- <message_argument value="5.2.3"/>
+ <message_argument value="5.1.8"/>
<message_argument value="touch(Path)"/>
</message_arguments>
</filter>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index 687c7a4fdd..64dbf58233 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -294,6 +294,8 @@ public abstract class FS {
Path probe = dir.resolve(".probe-" + UUID.randomUUID()); //$NON-NLS-1$
try {
Files.createFile(probe);
+ // ensure we always use the local system clock
+ FileUtils.touch(probe);
long wait = 512;
long start = System.nanoTime();
FileTime t1 = Files.getLastModifiedTime(probe);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
index 9bba6ca8a3..9650602fea 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java
@@ -49,7 +49,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.File;
import java.io.IOException;
-import java.io.OutputStream;
+import java.nio.channels.FileChannel;
import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.CopyOption;
import java.nio.file.Files;
@@ -57,6 +57,7 @@ import java.nio.file.InvalidPathException;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
@@ -66,6 +67,7 @@ import java.nio.file.attribute.PosixFilePermission;
import java.text.MessageFormat;
import java.text.Normalizer;
import java.text.Normalizer.Form;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -916,11 +918,13 @@ public class FileUtils {
* @param f
* the file to touch
* @throws IOException
- * @since 5.2.3
+ * @since 5.1.8
*/
public static void touch(Path f) throws IOException {
- try (OutputStream fos = Files.newOutputStream(f)) {
- // touch the file
+ try (FileChannel fc = FileChannel.open(f, StandardOpenOption.CREATE,
+ StandardOpenOption.APPEND, StandardOpenOption.SYNC)) {
+ // touch
}
+ Files.setLastModifiedTime(f, FileTime.from(Instant.now()));
}
}