1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +02:00

Bug 510054 - Unrecoverable index file corruption

Change-Id: I5ee83d637afd28388724a7402371fddb41e12c98
This commit is contained in:
Sergey Prigogin 2017-01-06 11:37:33 -08:00 committed by Gerrit Code Review @ Eclipse.org
parent 6adc3c29a6
commit fe3a787663

View file

@ -344,15 +344,15 @@ public class PDOMManager implements IWritableIndexManager, IListener {
* case a pdom ready to use is returned.
* @throws CoreException
*/
private WritablePDOM getOrCreatePDOM(ICProject project, IProgressMonitor monitor) throws CoreException {
private WritablePDOM getOrCreatePDOM(ICProject cProject, IProgressMonitor monitor) throws CoreException {
synchronized (fProjectToPDOM) {
IProject rproject = project.getProject();
IPDOM pdomProxy= fProjectToPDOM.get(rproject);
IProject project = cProject.getProject();
IPDOM pdomProxy= fProjectToPDOM.get(project);
if (pdomProxy instanceof WritablePDOM) {
return (WritablePDOM) pdomProxy;
}
String dbName= rproject.getPersistentProperty(dbNameProperty);
String dbName= project.getPersistentProperty(dbNameProperty);
File dbFile= null;
if (dbName != null) {
dbFile= fileFromDatabaseName(dbName);
@ -375,13 +375,23 @@ public class PDOMManager implements IWritableIndexManager, IListener {
boolean fromScratch= false;
if (dbName == null) {
dbName = createNewDatabaseName(project);
dbName = createNewDatabaseName(cProject);
dbFile= fileFromDatabaseName(dbName);
storeDatabaseName(rproject, dbName);
storeDatabaseName(project, dbName);
fromScratch= true;
}
WritablePDOM pdom= new WritablePDOM(dbFile, new PDOMProjectIndexLocationConverter(rproject), getLinkageFactories());
WritablePDOM pdom;
try {
pdom= new WritablePDOM(dbFile, new PDOMProjectIndexLocationConverter(project), getLinkageFactories());
} catch (CoreException e) {
CCorePlugin.log("Failed to open C/C++ index " + dbFile.getAbsolutePath() //$NON-NLS-1$
+ " - rebuilding the index", e); //$NON-NLS-1$
dbFile.delete();
fromScratch= true;
pdom= new WritablePDOM(dbFile, new PDOMProjectIndexLocationConverter(project), getLinkageFactories());
}
if (!pdom.isSupportedVersion() || fromScratch) {
try {
pdom.acquireWriteLock(monitor);
@ -394,14 +404,14 @@ public class PDOMManager implements IWritableIndexManager, IListener {
pdom.clear();
pdom.setClearedBecauseOfVersionMismatch(true);
}
writeProjectPDOMProperties(pdom, rproject);
writeProjectPDOMProperties(pdom, project);
pdom.releaseWriteLock();
}
pdom.setASTFilePathResolver(new ProjectIndexerInputAdapter(project, false));
pdom.setASTFilePathResolver(new ProjectIndexerInputAdapter(cProject, false));
pdom.addListener(this);
fFileToProject.put(dbFile, project);
fProjectToPDOM.put(rproject, pdom);
fFileToProject.put(dbFile, cProject);
fProjectToPDOM.put(project, pdom);
if (pdomProxy instanceof PDOMProxy) {
((PDOMProxy) pdomProxy).setDelegate(pdom);
}