@ -208,7 +208,7 @@ public abstract class FS {
FileStore s = Files . getFileStore ( dir ) ;
FileStore s = Files . getFileStore ( dir ) ;
FileStoreAttributeCache c = attributeCache . get ( s ) ;
FileStoreAttributeCache c = attributeCache . get ( s ) ;
if ( c = = null ) {
if ( c = = null ) {
c = new FileStoreAttributeCache ( dir ) ;
c = new FileStoreAttributeCache ( s , dir ) ;
attributeCache . put ( s , c ) ;
attributeCache . put ( s , c ) ;
if ( LOG . isDebugEnabled ( ) ) {
if ( LOG . isDebugEnabled ( ) ) {
LOG . debug ( c . toString ( ) ) ;
LOG . debug ( c . toString ( ) ) ;
@ -228,16 +228,24 @@ public abstract class FS {
return fsTimestampResolution ;
return fsTimestampResolution ;
}
}
private FileStoreAttributeCache ( Path dir )
private FileStoreAttributeCache ( FileStore s , Path dir )
throws IOException , InterruptedException {
throws IOException , InterruptedException {
Path probe = dir . resolve ( ".probe-" + UUID . randomUUID ( ) ) ; //$NON-NLS-1$
Path probe = dir . resolve ( ".probe-" + UUID . randomUUID ( ) ) ; //$NON-NLS-1$
Files . createFile ( probe ) ;
Files . createFile ( probe ) ;
try {
try {
long start = System . nanoTime ( ) ;
FileTime startTime = Files . getLastModifiedTime ( probe ) ;
FileTime startTime = Files . getLastModifiedTime ( probe ) ;
FileTime actTime = startTime ;
FileTime actTime = startTime ;
long sleepTime = 512 ;
long sleepTime = 512 ;
while ( actTime . compareTo ( startTime ) < = 0 ) {
while ( actTime . compareTo ( startTime ) < = 0 ) {
TimeUnit . NANOSECONDS . sleep ( sleepTime ) ;
TimeUnit . NANOSECONDS . sleep ( sleepTime ) ;
if ( timeout ( start ) ) {
LOG . warn ( MessageFormat . format ( JGitText
. get ( ) . timeoutMeasureFsTimestampResolution ,
s . toString ( ) ) ) ;
fsTimestampResolution = FALLBACK_TIMESTAMP_RESOLUTION ;
return ;
}
FileUtils . touch ( probe ) ;
FileUtils . touch ( probe ) ;
actTime = Files . getLastModifiedTime ( probe ) ;
actTime = Files . getLastModifiedTime ( probe ) ;
// limit sleep time to max. 100ms
// limit sleep time to max. 100ms
@ -254,6 +262,11 @@ public abstract class FS {
}
}
}
}
private static boolean timeout ( long start ) {
return System . nanoTime ( ) - start > = FALLBACK_TIMESTAMP_RESOLUTION
. toNanos ( ) ;
}
@SuppressWarnings ( "nls" )
@SuppressWarnings ( "nls" )
@Override
@Override
public String toString ( ) {
public String toString ( ) {