Index: IndexWriter.java =================================================================== --- IndexWriter.java (revision 386041) +++ IndexWriter.java (working copy) @@ -588,12 +588,13 @@ new Lock.With(directory.makeLock(COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT) { public Object doBody() throws IOException { segmentInfos.write(directory); // commit changes - deleteSegments(segmentsToDelete); // delete now-unused segments return null; } }.run(); } + deleteSegments(segmentsToDelete); // delete now-unused segments + if (useCompoundFile) { final Vector filesToDelete = merger.createCompoundFile(mergedName + ".tmp"); synchronized (directory) { // in- & inter-process sync @@ -601,12 +602,13 @@ public Object doBody() throws IOException { // make compound file visible for SegmentReaders directory.renameFile(mergedName + ".tmp", mergedName + ".cfs"); - // delete now unused files of segment - deleteFiles(filesToDelete); return null; } }.run(); } + + // delete now unused files of segment + deleteFiles(filesToDelete); } } @@ -696,12 +698,13 @@ new Lock.With(directory.makeLock(COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT) { public Object doBody() throws IOException { segmentInfos.write(directory); // commit before deleting - deleteSegments(segmentsToDelete); // delete now-unused segments return null; } }.run(); } + deleteSegments(segmentsToDelete); // delete now-unused segments + if (useCompoundFile) { final Vector filesToDelete = merger.createCompoundFile(mergedName + ".tmp"); synchronized (directory) { // in- & inter-process sync @@ -709,12 +712,13 @@ public Object doBody() throws IOException { // make compound file visible for SegmentReaders directory.renameFile(mergedName + ".tmp", mergedName + ".cfs"); - // delete now unused files of segment - deleteFiles(filesToDelete); return null; } }.run(); } + + // delete now unused files of segment + deleteFiles(filesToDelete); } }