Bug 70403 - Hardcoded paths make copy of workspace unusable and eventually corrupt the original one
Summary: Hardcoded paths make copy of workspace unusable and eventually corrupt the or...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-20 05:16 EDT by Dani Megert CLA
Modified: 2004-09-06 10:30 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2004-07-20 05:16:57 EDT
R3.0

I copied an existing workspace but had several problems due to hard coded paths
in files. One of them was:
.metadata\.plugins\org.eclipse.jdt.core\savedIndexNames.txt

The very bad thing about this is that it points into my original workspace and I
then can get very strange behavior and even modify/corrupt the original workspace.

I think it should be possible to copy an existing workspace and then use it
without running into various problems.
Comment 1 Dani Megert CLA 2004-07-20 07:20:28 EDT
R3.0

I copied an existing workspace but had several problems due to hard coded paths
in files. One of them was caused by the launch configs in:
.metadata\.plugins\org.eclipse.debug.core\.launches

The very bad thing about this is that it points into my original workspace and I
then can get very strange behavior and even modify/corrupt the original workspace.

I think it should be possible to copy an existing workspace and then use it
without running into various problems.
Comment 2 Dani Megert CLA 2004-07-20 07:21:02 EDT
Ignore comment 1 - it was meant for Debug's bug.
Comment 3 Philipe Mulet CLA 2004-07-20 12:44:33 EDT
Kent - can you check this ? When copying workspace, it shouldn't interfere 
with original one.
Comment 4 Dani Megert CLA 2004-07-20 12:58:37 EDT
Note: checked for all refs to my orignal workspace and this one showed up. No
direct indication that this causes harm.
Comment 5 Kent Johnson CLA 2004-07-20 13:13:20 EDT
Its not going to corrupt your workspace but search results can definitely be 
inaccurate.
Comment 6 Kent Johnson CLA 2004-07-20 13:51:46 EDT
Fred: Since you now own indexing, I'll let you 'fix' this one. ;)


I suspect all we need is to change the IndexManager in 2 places:

private String savedIndexFileName = "savedIndexNames.txt";  //$NON-NLS-1$
private File savedIndexNamesFile = new File(getJavaPluginWorkingLocation
().append(savedIndexFileName).toOSString());

and:

private SimpleLookupTable getIndexStates() {
	if (indexStates != null) return indexStates;

	this.indexStates = new SimpleLookupTable();
	char[] savedIndexNames = readIndexState();
	if (savedIndexNames.length > 0) {
		// must ensure that the saved path matches the expected path, 
otherwise workspace was moved
		char[] pathToFolder = savedIndexNamesFile.getName().toCharArray
();
		pathToFolder = CharOperation.subarray(pathToFolder, 0, 
pathToFolder.length - savedIndexFileName.length());
		char[][] names = CharOperation.splitOn('\n', savedIndexNames);
		for (int i = 0, l = names.length; i < l; i++) {
			char[] name = names[i];
			if (name.length > 0 && CharOperation.prefixEquals
(name, pathToFolder, true))
				this.indexStates.put(new String(name), 
SAVED_STATE);
		}
	}
	return this.indexStates;
}
Comment 7 Dani Megert CLA 2004-07-21 03:45:34 EDT
Re: comment 5: what about Open Type?
Comment 8 Frederic Fusier CLA 2004-07-21 06:21:08 EDT
Kent, I own Search engine from now but not indexing.
So you can release 'my' fix ;)
Comment 9 Kent Johnson CLA 2004-07-21 11:58:05 EDT
Fixed in 3.0.1 maintance stream & HEAD.

Dani: Open Type will get the wrong answer, but the workspace should not be 
corrupted.
Comment 10 Philipe Mulet CLA 2004-07-22 06:11:40 EDT
Kent - how will this fix perform when reopening a 3.0 workspace ? Is it going 
to cause entire reindexing ?
Comment 11 Philipe Mulet CLA 2004-07-22 06:12:38 EDT
Note that fix for bug 69028 caused entire reindexing anyway.
Comment 12 Kent Johnson CLA 2004-07-22 09:54:48 EDT
It will only cause reindexing if the jdt_core plugin location has moved.
Comment 13 David Audel CLA 2004-09-06 10:30:05 EDT
Verified for 3.0.1 RC1