diff options
author | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:28:18 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:28:18 -0700 |
commit | d76e3920c56d37c942092b7dca20fcaded81c0a5 (patch) | |
tree | 80a55c7b59c38377216daaada4e8bc47b69ceb9a /platform/util/src/com/intellij/util/io/RandomAccessDataFile.java | |
parent | 3b37877a2561bf9fbe072253a18688807d523505 (diff) | |
parent | 1aa2e09bdbd413eacb677e9fa4b50630530d0656 (diff) | |
download | idea-d76e3920c56d37c942092b7dca20fcaded81c0a5.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master' into merge
Conflicts:
.idea/modules.xml
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java
Change-Id: Id899dae9a1e1c79272f8a70e14a7dcef4f760d7f
Diffstat (limited to 'platform/util/src/com/intellij/util/io/RandomAccessDataFile.java')
-rw-r--r-- | platform/util/src/com/intellij/util/io/RandomAccessDataFile.java | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java index 9a297bcef6d1..d4383a55d03e 100644 --- a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java +++ b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,11 +47,11 @@ public class RandomAccessDataFile implements Forceable, Closeable { private static final boolean DEBUG = false; - public RandomAccessDataFile(final File file) throws IOException { + public RandomAccessDataFile(@NotNull File file) throws IOException { this(file, PagePool.SHARED); } - public RandomAccessDataFile(final File file, final PagePool pool) throws IOException { + public RandomAccessDataFile(@NotNull File file, @NotNull PagePool pool) throws IOException { myPool = pool; myFile = file; if (!file.exists()) { @@ -201,6 +201,9 @@ public class RandomAccessDataFile implements Forceable, Closeable { dispose(); } + /** + * Flushes dirty pages to underlying buffers + */ @Override public void force() { assertNotDisposed(); @@ -210,6 +213,23 @@ public class RandomAccessDataFile implements Forceable, Closeable { } } + /** + * Flushes dirty pages to buffers and saves them to disk + */ + public void sync() { + force(); + try { + RandomAccessFile file = getRandomAccessFile(); + file.getChannel().force(true); + } + catch (IOException ignored) { + + } + finally { + releaseFile(); + } + } + public void flushSomePages(int maxPagesToFlush) { assertNotDisposed(); if (isDirty()) { @@ -229,7 +249,7 @@ public class RandomAccessDataFile implements Forceable, Closeable { private void assertNotDisposed() { if (myIsDisposed) { - LOG.assertTrue(false, "storage file is disposed: " + myFile); + LOG.error("storage file is disposed: " + myFile); } } @@ -316,6 +336,7 @@ public class RandomAccessDataFile implements Forceable, Closeable { file.seek(fileOffset); } + @Override public int hashCode() { return myCount; } |