Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrx committed Oct 19, 2021
1 parent 174954f commit 3bbef1e
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ protected void closeInternal() {
private volatile FileChannelReference channelRef;

/**
* Indicates if the file should be created when it is open for the first time.
* This is required to pass the right options for sparse file support.
* {@code true} if the physical cache file exists on disk
*/
private volatile boolean created;
private volatile boolean fileExists;

public CacheFile(CacheKey cacheKey, long length, Path file, ModificationListener listener) {
this(cacheKey, new SparseFileTracker(file.toString(), length), file, listener, false);
Expand All @@ -146,7 +145,7 @@ private CacheFile(CacheKey cacheKey, SparseFileTracker tracker, Path file, Modif
this.file = Objects.requireNonNull(file);
this.listener = Objects.requireNonNull(listener);
assert fileExists == Files.exists(file) : file + " exists? " + fileExists;
this.created = fileExists;
this.fileExists = fileExists;
assert invariant();
}

Expand Down Expand Up @@ -192,8 +191,8 @@ public void acquire(final EvictionListener listener) throws IOException {
ensureOpen();
if (listeners.isEmpty()) {
assert channelRef == null;
channelRef = new FileChannelReference(created ? OPEN_OPTIONS : CREATE_OPTIONS);
created = true;
channelRef = new FileChannelReference(fileExists ? OPEN_OPTIONS : CREATE_OPTIONS);
fileExists = true;
}
final boolean added = listeners.add(listener);
assert added : "listener already exists " + listener;
Expand Down

0 comments on commit 3bbef1e

Please sign in to comment.