public static void fsync(final File file) throws IOException {
        final boolean isDir = file.isDirectory();
        // can't fsync on windows.
        if (isDir && Platform.isWindows()) {
            LOG.warn("Unable to fsync directory {} on windows.", file);
            return;
        }
        try (final FileChannel fc = FileChannel.open(file.toPath(), isDir ? StandardOpenOption.READ
            : StandardOpenOption.WRITE)) {
            fc.force(true);
        }
    }
Calls fsync on a file or directory.

@param file file or directory
@throws IOException if an I/O error occurs
jraft-core/src/main/java/com/alipay/sofa/jraft/util/Utils.java