diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-08-05 00:51:04 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-08-06 14:54:39 +0200 |
commit | 275f3da783b025a3e6cfe47eedc7876e911269f3 (patch) | |
tree | 96daa3b1702c37ec90d1520de0881ca6a4402797 /org.eclipse.jgit | |
parent | d45219baacab711abf3c4112146ca0522d984be2 (diff) | |
download | jgit-275f3da783b025a3e6cfe47eedc7876e911269f3.tar.gz jgit-275f3da783b025a3e6cfe47eedc7876e911269f3.zip |
Fix FileSnapshot#save(long) and FileSnapshot#save(Instant)
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>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java index e81a88451b..77005100ef 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java @@ -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. */ 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 16810e0dc3..c30be36dde 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -214,12 +214,19 @@ public abstract class FS { .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<>(); |