/** * Returns an unbuffered input stream to read the last committed value, or null if no value has * been committed. */ public Source newSource(int index) { synchronized (DiskLruCache.this) { if (done) { throw new IllegalStateException(); } if (!entry.readable || entry.currentEditor != this) { return null; } try { return fileSystem.source(entry.cleanFiles[index]); } catch (FileNotFoundException e) { return null; } } }
/** * Returns an unbuffered input stream to read the last committed value, or null if no value has * been committed. */ public Source newSource(int index) { synchronized (DiskLruCache.this) { if (done) { throw new IllegalStateException(); } if (!entry.readable || entry.currentEditor != this) { return null; } try { return fileSystem.source(entry.cleanFiles[index]); } catch (FileNotFoundException e) { return null; } } }
try { for (int i = 0; i < valueCount; i++) { sources[i] = fileSystem.source(cleanFiles[i]);
private void readJournal() throws IOException { try (BufferedSource source = Okio.buffer(fileSystem.source(journalFile))) { String magic = source.readUtf8LineStrict(); String version = source.readUtf8LineStrict();
try { for (int i = 0; i < valueCount; i++) { sources[i] = fileSystem.source(cleanFiles[i]);
private void readJournal() throws IOException { try (BufferedSource source = Okio.buffer(fileSystem.source(journalFile))) { String magic = source.readUtf8LineStrict(); String version = source.readUtf8LineStrict();
/** * Returns an unbuffered input stream to read the last committed value, or null if no value has * been committed. */ public Source newSource(int index) { synchronized (DiskLruCache.this) { if (done) { throw new IllegalStateException(); } if (!entry.readable || entry.currentEditor != this) { return null; } try { return fileSystem.source(entry.cleanFiles[index]); } catch (FileNotFoundException e) { return null; } } }
/** * Returns an unbuffered input stream to read the last committed value, * or null if no value has been committed. */ public Source newSource(int index) throws IOException { synchronized (DiskLruCache.this) { if (entry.currentEditor != this) { throw new IllegalStateException(); } if (!entry.readable) { return null; } try { return fileSystem.source(entry.cleanFiles[index]); } catch (FileNotFoundException e) { return null; } } }
/** * Returns an unbuffered input stream to read the last committed value, or null if no value has * been committed. */ public Source newSource(int index) { synchronized (DiskLruCache.this) { if (done) { throw new IllegalStateException(); } if (!entry.readable || entry.currentEditor != this) { return null; } try { return fileSystem.source(entry.cleanFiles[index]); } catch (FileNotFoundException e) { return null; } } }
/** * Returns an unbuffered input stream to read the last committed value, or null if no value has * been committed. */ public Source newSource(int index) throws IOException { synchronized (DiskLruCache.this) { if (entry.currentEditor != this) { throw new IllegalStateException(); } if (!entry.readable) { return null; } try { return fileSystem.source(entry.cleanFiles[index]); } catch (FileNotFoundException e) { return null; } } }
/** * Returns an unbuffered input stream to read the last committed value, * or null if no value has been committed. */ public Source newSource(int index) throws IOException { synchronized (DiskLruCache.this) { if (entry.currentEditor != this) { throw new IllegalStateException(); } if (!entry.readable) { return null; } try { return fileSystem.source(entry.cleanFiles[index]); } catch (FileNotFoundException e) { return null; } } }
/** * Returns a snapshot of this entry. This opens all streams eagerly to guarantee that we see a * single published snapshot. If we opened streams lazily then the streams could come from * different edits. */ Snapshot snapshot() { if (!Thread.holdsLock(DiskLruCache.this)) throw new AssertionError(); Source[] sources = new Source[valueCount]; long[] lengths = this.lengths.clone(); // Defensive copy since these can be zeroed out. try { for (int i = 0; i < valueCount; i++) { sources[i] = fileSystem.source(cleanFiles[i]); } return new Snapshot(key, sequenceNumber, sources, lengths); } catch (FileNotFoundException e) { // A file must have been deleted manually! for (int i = 0; i < valueCount; i++) { if (sources[i] != null) { Util.closeQuietly(sources[i]); } else { break; } } return null; } } }
/** * Returns a snapshot of this entry. This opens all streams eagerly to guarantee that we see a * single published snapshot. If we opened streams lazily then the streams could come from * different edits. */ Snapshot snapshot() { if (!Thread.holdsLock(DiskLruCache.this)) throw new AssertionError(); Source[] sources = new Source[valueCount]; long[] lengths = this.lengths.clone(); // Defensive copy since these can be zeroed out. try { for (int i = 0; i < valueCount; i++) { sources[i] = fileSystem.source(cleanFiles[i]); } return new Snapshot(key, sequenceNumber, sources, lengths); } catch (FileNotFoundException e) { // A file must have been deleted manually! for (int i = 0; i < valueCount; i++) { if (sources[i] != null) { Util.closeQuietly(sources[i]); } else { break; } } return null; } } }
/** * Returns a snapshot of this entry. This opens all streams eagerly to guarantee that we see a * single published snapshot. If we opened streams lazily then the streams could come from * different edits. */ Snapshot snapshot() { if (!Thread.holdsLock(DiskLruCache.this)) throw new AssertionError(); Source[] sources = new Source[valueCount]; long[] lengths = this.lengths.clone(); // Defensive copy since these can be zeroed out. try { for (int i = 0; i < valueCount; i++) { sources[i] = fileSystem.source(cleanFiles[i]); } return new Snapshot(key, sequenceNumber, sources, lengths); } catch (FileNotFoundException e) { // A file must have been deleted manually! for (int i = 0; i < valueCount; i++) { if (sources[i] != null) { Util.closeQuietly(sources[i]); } else { break; } } return null; } } }
try { for (int i = 0; i < valueCount; i++) { sources[i] = fileSystem.source(cleanFiles[i]);
try { for (int i = 0; i < valueCount; i++) { sources[i] = fileSystem.source(cleanFiles[i]);
private void readJournal() throws IOException { BufferedSource source = Okio.buffer(fileSystem.source(journalFile)); try { String magic = source.readUtf8LineStrict();
private void readJournal() throws IOException { BufferedSource source = Okio.buffer(fileSystem.source(journalFile)); try { String magic = source.readUtf8LineStrict();
private void readJournal() throws IOException { BufferedSource source = Okio.buffer(fileSystem.source(journalFile)); try { String magic = source.readUtf8LineStrict();
private void readJournal() throws IOException { BufferedSource source = Okio.buffer(fileSystem.source(journalFile)); try { String magic = source.readUtf8LineStrict();