1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 15:05:36 +02:00

[153635] [dstore-linux] dangling symbolic links are not classified properly

This commit is contained in:
David McKnight 2011-03-08 18:59:08 +00:00
parent 219fb467b8
commit 701637eef6

View file

@ -20,6 +20,7 @@
* David McKnight (IBM) - [251729][dstore] problems querying symbolic link folder * David McKnight (IBM) - [251729][dstore] problems querying symbolic link folder
* Noriaki Takatsu (IBM) - [256724] thread-level security is not established * Noriaki Takatsu (IBM) - [256724] thread-level security is not established
* David McKnight (IBM) - [283613] [dstore] Create a Constants File for all System Properties we support * David McKnight (IBM) - [283613] [dstore] Create a Constants File for all System Properties we support
* David McKnight (IBM) - [153635] [dstore-linux] dangling symbolic links are not classified properly
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.filesystem; package org.eclipse.rse.internal.dstore.universal.miners.filesystem;
@ -163,7 +164,8 @@ public class FileClassifier extends SecuredThread
// determine if we are classifying virtual files // determine if we are classifying virtual files
// we are if the subject is an archive, virtual folder or a virtual file // we are if the subject is an archive, virtual folder or a virtual file
if (objType.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR) || objType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR) if (objType.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR) ||
objType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR)
|| objType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)) || objType.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR))
{ {
_classifyVirtual = true; _classifyVirtual = true;
@ -191,28 +193,30 @@ public class FileClassifier extends SecuredThread
DataElement child = _subject.get(i); DataElement child = _subject.get(i);
if (child != null && !child.isDeleted()) if (child != null && !child.isDeleted())
{ {
if (child.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) String type = child.getType();
|| child.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR) if (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR)
|| child.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR)) || type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
{ || type.equals(IUniversalDataStoreConstants.UNIVERSAL_FOLDER_DESCRIPTOR)
String name = child.getName(); || type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR))
String properties = child.getSource(); {
String name = child.getName();
String properties = child.getSource();
// if this file has already been classified // if this file has already been classified
// ignore it // ignore it
String[] tokens = properties.split("\\" + IServiceConstants.TOKEN_SEPARATOR); //$NON-NLS-1$ String[] tokens = properties.split("\\" + IServiceConstants.TOKEN_SEPARATOR); //$NON-NLS-1$
if (tokens.length < 12) if (tokens.length < 12)
{ {
putElement(name, child); putElement(name, child);
} }
/* /*
* StringTokenizer tokenizer = new * StringTokenizer tokenizer = new
* StringTokenizer(properties, * StringTokenizer(properties,
* IUniversalDataStoreConstants.TOKEN_SEPARATOR); if * IUniversalDataStoreConstants.TOKEN_SEPARATOR); if
* (tokenizer.countTokens() < 12) { putElement(name, child); } * (tokenizer.countTokens() < 12) { putElement(name, child); }
*/ */
} }
} }
} }
@ -791,10 +795,9 @@ public class FileClassifier extends SecuredThread
StringBuffer path = new StringBuffer(element.getValue()); StringBuffer path = new StringBuffer(element.getValue());
path.append(File.separatorChar); path.append(File.separatorChar);
path.append(element.getName()); path.append(element.getName());
File refFile = new File(path.toString());
// canonical file path // canonical file path
String canonicalPath = null; String canonicalPath = null;
// if the file is a link resolve it // if the file is a link resolve it
@ -802,7 +805,7 @@ public class FileClassifier extends SecuredThread
// to resolve links, ignore it // to resolve links, ignore it
if (type.equals(STR_SYMBOLIC_LINK) && !resolveLinks) if (type.equals(STR_SYMBOLIC_LINK) && !resolveLinks)
{ {
File refFile = new File(path.toString());
// get canonical file path // get canonical file path
canonicalPath = refFile.getCanonicalPath(); canonicalPath = refFile.getCanonicalPath();
@ -843,6 +846,7 @@ public class FileClassifier extends SecuredThread
if (type.equals(STR_SYMBOLIC_LINK)) if (type.equals(STR_SYMBOLIC_LINK))
{ {
File refFile = new File(path.toString());
canonicalPath = refFile.getCanonicalPath(); canonicalPath = refFile.getCanonicalPath();
} }
} }
@ -868,8 +872,9 @@ public class FileClassifier extends SecuredThread
String textToCheck = STR_SYMBOLIC_LINK; String textToCheck = STR_SYMBOLIC_LINK;
int linkIndex = currentProperties.lastIndexOf(textToCheck); int linkIndex = currentProperties.lastIndexOf(textToCheck);
// int brokenLink = currentProperties.lastIndexOf(STR_BROKEN_SYMBOLIC_LINK);
if (linkIndex != -1) if (linkIndex != -1)// && brokenLink == 0)
{ {
int cutOffIndex = linkIndex + textToCheck.length(); int cutOffIndex = linkIndex + textToCheck.length();
@ -905,6 +910,7 @@ public class FileClassifier extends SecuredThread
} }
} }
_dataStore.trace("out of loop");
if (reader != null) if (reader != null)
reader.close(); reader.close();
else else
@ -912,6 +918,7 @@ public class FileClassifier extends SecuredThread
// we have found links // we have found links
if (hasLinks) if (hasLinks)
{ {
_dataStore.trace("has links");
// if we were told not to resolve them, but we are capable of // if we were told not to resolve them, but we are capable of
// doing so, then // doing so, then
// let's try again // let's try again