/** * Deletes all given files, suppressing all thrown IOExceptions. * <p> * Some of the files may be null, if so they are ignored. */ public static void deleteFilesIgnoringExceptions(Path... files) { deleteFilesIgnoringExceptions(Arrays.asList(files)); }
public static void deleteFilesIgnoringExceptions(Directory dir, String... files) { deleteFilesIgnoringExceptions(dir, Arrays.asList(files)); }
final void rollbackCommit(Directory dir) { if (pendingCommit) { pendingCommit = false; // we try to clean up our pending_segments_N // Must carefully compute fileName from "generation" // since lastGeneration isn't incremented: final String pending = IndexFileNames.fileNameFromGeneration(IndexFileNames.PENDING_SEGMENTS, "", generation); // Suppress so we keep throwing the original exception // in our caller IOUtils.deleteFilesIgnoringExceptions(dir, pending); } }
@Override void abort() { try { super.abort(); } finally { if (tmpDirectory != null) { IOUtils.deleteFilesIgnoringExceptions(tmpDirectory, tmpDirectory.getTemporaryFiles().values()); } } }
@Override public void abort() { try { super.abort(); } finally { if (tmpDirectory != null) { IOUtils.deleteFilesIgnoringExceptions(tmpDirectory, tmpDirectory.getTemporaryFiles().values()); } } }
synchronized private void persist() throws IOException { String fileName = SNAPSHOTS_PREFIX + nextWriteGen; IndexOutput out = dir.createOutput(fileName, IOContext.DEFAULT); boolean success = false; try { CodecUtil.writeHeader(out, CODEC_NAME, VERSION_CURRENT); out.writeVInt(refCounts.size()); for(Entry<Long,Integer> ent : refCounts.entrySet()) { out.writeVLong(ent.getKey()); out.writeVInt(ent.getValue()); } success = true; } finally { if (!success) { IOUtils.closeWhileHandlingException(out); IOUtils.deleteFilesIgnoringExceptions(dir, fileName); } else { IOUtils.close(out); } } dir.sync(Collections.singletonList(fileName)); if (nextWriteGen > 0) { String lastSaveFile = SNAPSHOTS_PREFIX + (nextWriteGen-1); // exception OK: likely it didn't exist IOUtils.deleteFilesIgnoringExceptions(dir, lastSaveFile); } nextWriteGen++; }
for(String file : snapshotFiles) { if (!curFileName.equals(file)) { IOUtils.deleteFilesIgnoringExceptions(dir, file);
/** * Copies an existing {@code src} file from directory {@code from} * to a non-existent file {@code dest} in this directory. */ public void copyFrom(Directory from, String src, String dest, IOContext context) throws IOException { boolean success = false; try (IndexInput is = from.openInput(src, context); IndexOutput os = createOutput(dest, context)) { os.copyBytes(is, is.length()); success = true; } finally { if (!success) { IOUtils.deleteFilesIgnoringExceptions(this, dest); } } }
} else { IOUtils.closeWhileHandlingException(out); IOUtils.deleteFilesIgnoringExceptions(first, toDelete);
IOUtils.deleteFilesIgnoringExceptions(dir, fileName);
private void write(Directory directory) throws IOException { long nextGeneration = getNextPendingGeneration(); String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.PENDING_SEGMENTS, "", nextGeneration); // Always advance the generation on write: generation = nextGeneration; IndexOutput segnOutput = null; boolean success = false; try { segnOutput = directory.createOutput(segmentFileName, IOContext.DEFAULT); write(directory, segnOutput); segnOutput.close(); directory.sync(Collections.singleton(segmentFileName)); success = true; } finally { if (success) { pendingCommit = true; } else { // We hit an exception above; try to close the file // but suppress any exception: IOUtils.closeWhileHandlingException(segnOutput); // Try not to leave a truncated segments_N file in // the index: IOUtils.deleteFilesIgnoringExceptions(directory, segmentFileName); } } }
} finally { if (success == false) { IOUtils.deleteFilesIgnoringExceptions(trackingDir, trackingDir.getCreatedFiles());
} finally { if (success == false) { IOUtils.deleteFilesIgnoringExceptions(tempDir, tempDir.getCreatedFiles()); IOUtils.closeWhileHandlingException(toCloseHeroically);
IOUtils.deleteFilesIgnoringExceptions(dir, fileName);
Files.delete(aff); } else { IOUtils.deleteFilesIgnoringExceptions(aff);
tempDir.deleteFile(unsorted.getName()); } else { IOUtils.deleteFilesIgnoringExceptions(tempDir, unsorted.getName()); tempDir.deleteFile(sorted); } else { IOUtils.deleteFilesIgnoringExceptions(tempDir, sorted);
/** * Deletes all given files, suppressing all thrown IOExceptions. * <p> * Some of the files may be null, if so they are ignored. */ public static void deleteFilesIgnoringExceptions(Path... files) { deleteFilesIgnoringExceptions(Arrays.asList(files)); }
/** * Deletes all given files, suppressing all thrown IOExceptions. * <p> * Some of the files may be null, if so they are ignored. */ public static void deleteFilesIgnoringExceptions(Path... files) { deleteFilesIgnoringExceptions(Arrays.asList(files)); }
@Override void abort() { try { super.abort(); } finally { if (tmpDirectory != null) { IOUtils.deleteFilesIgnoringExceptions(tmpDirectory, tmpDirectory.getTemporaryFiles().values()); } } }
@Override public void abort() { try { super.abort(); } finally { if (tmpDirectory != null) { IOUtils.deleteFilesIgnoringExceptions(tmpDirectory, tmpDirectory.getTemporaryFiles().values()); } } }