]> source.dussan.org Git - jgit.git/commitdiff
Fix FileSnapshot#save(long) and FileSnapshot#save(Instant) 26/147026/2
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 4 Aug 2019 22:51:04 +0000 (00:51 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 6 Aug 2019 12:54:39 +0000 (14:54 +0200)
Use the fallback timestamp resolution as already described in the
javadoc of these methods. Using zero file timestamp resolution doesn't
make sense.

Change-Id: Iaad2a0f99c3be3678e94980a0a368181b6aed38c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

index e81a88451b7949e29eb0eeb119ebfe9c8b0d3b38..77005100efd16f093855b4dbbab0152832d56f53 100644 (file)
@@ -44,7 +44,7 @@
 package org.eclipse.jgit.internal.storage.file;
 
 import static org.eclipse.jgit.util.FS.FileStoreAttributes.FALLBACK_FILESTORE_ATTRIBUTES;
-
+import static org.eclipse.jgit.util.FS.FileStoreAttributes.FALLBACK_TIMESTAMP_RESOLUTION;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.attribute.BasicFileAttributes;
@@ -176,7 +176,7 @@ public class FileSnapshot {
        public static FileSnapshot save(long modified) {
                final Instant read = Instant.now();
                return new FileSnapshot(read, Instant.ofEpochMilli(modified),
-                               UNKNOWN_SIZE, Duration.ZERO, MISSING_FILEKEY);
+                               UNKNOWN_SIZE, FALLBACK_TIMESTAMP_RESOLUTION, MISSING_FILEKEY);
        }
 
        /**
@@ -196,8 +196,8 @@ public class FileSnapshot {
         */
        public static FileSnapshot save(Instant modified) {
                final Instant read = Instant.now();
-               return new FileSnapshot(read, modified, UNKNOWN_SIZE, Duration.ZERO,
-                               MISSING_FILEKEY);
+               return new FileSnapshot(read, modified, UNKNOWN_SIZE,
+                               FALLBACK_TIMESTAMP_RESOLUTION, MISSING_FILEKEY);
        }
 
        /** Last observed modification time of the path. */
index 16810e0dc3bc854c95d66158749ec6c6b69325e3..c30be36ddefba8ee87b65e51cf5e4aa6784fd3f4 100644 (file)
@@ -213,13 +213,20 @@ public abstract class FS {
                private static final Duration UNDEFINED_DURATION = Duration
                                .ofNanos(Long.MAX_VALUE);
 
+               /**
+                * Fallback filesystem timestamp resolution. The worst case timestamp
+                * resolution on FAT filesystems is 2 seconds.
+                */
+               public static final Duration FALLBACK_TIMESTAMP_RESOLUTION = Duration
+                               .ofMillis(2000);
+
                /**
                 * Fallback FileStore attributes used when we can't measure the
                 * filesystem timestamp resolution. The last modified time granularity
                 * of FAT filesystems is 2 seconds.
                 */
                public static final FileStoreAttributes FALLBACK_FILESTORE_ATTRIBUTES = new FileStoreAttributes(
-                               Duration.ofMillis(2000));
+                               FALLBACK_TIMESTAMP_RESOLUTION);
 
                private static final Map<FileStore, FileStoreAttributes> attributeCache = new ConcurrentHashMap<>();