View | Details | Raw Unified | Return to bug 251504 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java (-2 / +1 lines)
Lines 179-186 Link Here
179
				// Index the jar for the first time or reindex the jar in case the previous index file has been corrupted
179
				// Index the jar for the first time or reindex the jar in case the previous index file has been corrupted
180
				// index already existed: recreate it so that we forget about previous entries
180
				// index already existed: recreate it so that we forget about previous entries
181
				SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
181
				SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
182
				index = this.manager.recreateIndex(this.containerPath);
182
				if (!this.manager.resetIndex(this.containerPath)) {
183
				if (index == null) {
184
					// failed to recreate index, see 73330
183
					// failed to recreate index, see 73330
185
					this.manager.removeIndex(this.containerPath);
184
					this.manager.removeIndex(this.containerPath);
186
					return false;
185
					return false;
(-)search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java (+29 lines)
Lines 622-627 Link Here
622
	this.indexLocations = new SimpleLookupTable();
622
	this.indexLocations = new SimpleLookupTable();
623
	this.javaPluginLocation = null;
623
	this.javaPluginLocation = null;
624
}
624
}
625
/**
626
 * Resets the index for a given path.
627
 * Returns true if the index was reset, false otherwise.
628
 */
629
public synchronized boolean resetIndex(IPath containerPath) {
630
	// only called to over write an existing cached index...
631
	String containerPathString = containerPath.getDevice() == null ? containerPath.toString() : containerPath.toOSString();
632
	try {
633
		if (VERBOSE) {
634
			Util.verbose("-> reseting index: "+indexLocation+" for path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$
635
		}
636
		// Path is already canonical
637
		IPath indexLocation = computeIndexLocation(containerPath);
638
		Index index = getIndex(indexLocation);
639
		if (index == null) {
640
			// the index does not exist, try to recreate it
641
			return recreateIndex(containerPath) != null;
642
		}
643
		index.reset(true/*reuse index file*/);
644
		return true;
645
	} catch (IOException e) {
646
		// The file could not be created. Possible reason: the project has been deleted.
647
		if (VERBOSE) {
648
			Util.verbose("-> failed to reset index for path: "+containerPathString); //$NON-NLS-1$
649
			e.printStackTrace();
650
		}
651
		return false;
652
	}
653
}
625
public void saveIndex(Index index) throws IOException {
654
public void saveIndex(Index index) throws IOException {
626
	// must have permission to write from the write monitor
655
	// must have permission to write from the write monitor
627
	if (index.hasChanged()) {
656
	if (index.hasChanged()) {
(-)search/org/eclipse/jdt/internal/core/index/Index.java (+10 lines)
Lines 172-177 Link Here
172
public void remove(String containerRelativePath) {
172
public void remove(String containerRelativePath) {
173
	this.memoryIndex.remove(containerRelativePath);
173
	this.memoryIndex.remove(containerRelativePath);
174
}
174
}
175
/**
176
 * Reset memory and disk indexes.
177
 * 
178
 * @throws IOException
179
 */
180
public void reset(boolean reuseExistingFile) throws IOException {
181
	this.memoryIndex = new MemoryIndex();
182
	this.diskIndex = new DiskIndex(this.diskIndex.indexFile.getCanonicalPath());
183
	this.diskIndex.initialize(reuseExistingFile);
184
}
175
public void save() throws IOException {
185
public void save() throws IOException {
176
	// must own the write lock of the monitor
186
	// must own the write lock of the monitor
177
	if (!hasChanged()) return;
187
	if (!hasChanged()) return;

Return to bug 251504