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

[191548] fix: Deleting Read-Only directory removes it from view and displays no error

This commit is contained in:
Xuan Chen 2007-08-23 15:26:07 +00:00
parent b32bc6595b
commit acd2bd19c2
4 changed files with 96 additions and 61 deletions

View file

@ -2123,7 +2123,7 @@ public class UniversalFileSystemMiner extends Miner {
.getRegisteredHandler(new File(vpath .getRegisteredHandler(new File(vpath
.getContainingArchiveString())); .getContainingArchiveString()));
if (handler == null || !handler.delete(vpath.getVirtualPart())) { if (handler == null || !handler.delete(vpath.getVirtualPart())) {
status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED); status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED + "|" + vpath.toString()); //$NON-NLS-1$
_dataStore.refresh(subject); _dataStore.refresh(subject);
return statusDone(status); return statusDone(status);
} }

View file

@ -10,6 +10,7 @@
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * {Name} (company) - description of contribution.
* Kevin Doyle (IBM) - [191548] Deleting Read-Only directory removes it from view and displays no error
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.dstore.universal.miners.filesystem; package org.eclipse.rse.internal.dstore.universal.miners.filesystem;
@ -114,7 +115,7 @@ public class ArchiveQueryThread extends QueryThread {
virtualPath = avp.getVirtualPart(); virtualPath = avp.getVirtualPart();
fileobj = new File(rootPath); fileobj = new File(rootPath);
if (fileobj.exists()) { if (fileobj.exists() && mgr.getVirtualObject(path).exists()) {
if (_foldersOnly) { if (_foldersOnly) {
children = mgr.getFolderContents(fileobj, children = mgr.getFolderContents(fileobj,
@ -132,6 +133,20 @@ public class ArchiveQueryThread extends QueryThread {
if (isCancelled()) if (isCancelled())
return; return;
} else { } else {
// Update the properties so the file's exists() will return false
_subject.setAttribute(DE.A_TYPE, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR);
_subject.setAttribute(DE.A_SOURCE, setProperties(fileobj));
_status.setAttribute(DE.A_SOURCE, IServiceConstants.FAILED_WITH_DOES_NOT_EXIST);
// Update all the children showing that they are deleted.
if (_subject.getNestedSize() > 0)
{
List nestedChildren = _subject.getNestedData();
for (int i = nestedChildren.size() - 1; i >= 0; i--)
{
_dataStore.deleteObject(_subject, (DataElement) nestedChildren.get(i));
}
}
_dataStore.trace("problem with File:" + rootPath); //$NON-NLS-1$ _dataStore.trace("problem with File:" + rootPath); //$NON-NLS-1$
} }
} }
@ -226,63 +241,64 @@ public class ArchiveQueryThread extends QueryThread {
// Check if the current Objects in the DataStore are valid... exist // Check if the current Objects in the DataStore are valid... exist
// on the remote host // on the remote host
try { try {
boolean found = false; if (list != null) {
for (int j = 0; j < list.length; ++j) { boolean found = false;
if (isCancelled()) for (int j = 0; j < list.length; ++j) {
return; if (isCancelled())
return;
found = false; found = false;
DataElement previousElement = (DataElement) filteredChildren DataElement previousElement = (DataElement) filteredChildren
.get(list[j].name); .get(list[j].name);
if (previousElement != null && !previousElement.isDeleted()) { if (previousElement != null && !previousElement.isDeleted()) {
// Type have to be equal as well // Type have to be equal as well
String type = previousElement.getType(); String type = previousElement.getType();
boolean isfile = !list[j].isDirectory; boolean isfile = !list[j].isDirectory;
if (type if (type
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR) .equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
|| (type || (type
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR) && !isfile)) { .equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR) && !isfile)) {
filteredChildren.remove(list[j].name); filteredChildren.remove(list[j].name);
found = true; found = true;
}
} }
} DataElement deObj = null;
DataElement deObj = null; VirtualChild child = list[j];
VirtualChild child = list[j];
if (found) { if (found) {
deObj = previousElement; deObj = previousElement;
} }
if (deObj == null) { if (deObj == null) {
if (child.isDirectory) { if (child.isDirectory) {
deObj = _dataStore deObj = _dataStore
.createObject( .createObject(
subject, subject,
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR, IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR,
child.name); child.name);
} else // file } else // file
{ {
deObj = _dataStore deObj = _dataStore
.createObject( .createObject(
subject, subject,
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR, IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR,
child.name); child.name);
}
}
String oldValue = deObj.getAttribute(DE.A_VALUE);
String newValue = rootPath
+ ArchiveHandlerManager.VIRTUAL_SEPARATOR + virtualPath;
if (!oldValue.equals(newValue)) {
deObj.setAttribute(DE.A_VALUE, newValue);
}
String oldSource = deObj.getAttribute(DE.A_SOURCE);
String newSource = setProperties(child);
if (!oldSource.startsWith(newSource)) {
deObj.setAttribute(DE.A_SOURCE, newSource);
} }
} } // end for j
String oldValue = deObj.getAttribute(DE.A_VALUE); }
String newValue = rootPath
+ ArchiveHandlerManager.VIRTUAL_SEPARATOR + virtualPath;
if (!oldValue.equals(newValue)) {
deObj.setAttribute(DE.A_VALUE, newValue);
}
String oldSource = deObj.getAttribute(DE.A_SOURCE);
String newSource = setProperties(child);
if (!oldSource.startsWith(newSource)) {
deObj.setAttribute(DE.A_SOURCE, newSource);
}
} // end for j
// Object left over in the filteredChildren is no longer in the // Object left over in the filteredChildren is no longer in the
// system any more. Need to remove. // system any more. Need to remove.
Iterator myIterator = filteredChildren.keySet().iterator(); Iterator myIterator = filteredChildren.keySet().iterator();

View file

@ -929,7 +929,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
DataElement de = getElementFor(remotePath); DataElement de = getElementFor(remotePath);
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_DELETE, monitor); DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_DELETE, monitor);
if (status == null) return false; if (status == null) return false;
if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) { String sourceMsg = FileSystemMessageUtil.getSourceMessage(status);
// When running a server older than 2.0.1 success is not set for directories, so we must
// check if the source message is an empty string
if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$
return true; return true;
} else { } else {
throw new SystemMessageException(getMessage("RSEF1300").makeSubstitution(FileSystemMessageUtil.getSourceLocation(status))); //$NON-NLS-1$ throw new SystemMessageException(getMessage("RSEF1300").makeSubstitution(FileSystemMessageUtil.getSourceLocation(status))); //$NON-NLS-1$
@ -949,7 +952,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
DataElement status = dsStatusCommand((DataElement) dataElements.get(0), dataElements, IUniversalDataStoreConstants.C_DELETE_BATCH, monitor); DataElement status = dsStatusCommand((DataElement) dataElements.get(0), dataElements, IUniversalDataStoreConstants.C_DELETE_BATCH, monitor);
if (status == null) return false; if (status == null) return false;
if (FileSystemMessageUtil.getSourceMessage(status).equals(IServiceConstants.SUCCESS)) { String sourceMsg = FileSystemMessageUtil.getSourceMessage(status);
// When running a server older than 2.0.1 success is not set for directories, so we must
// check if the source message is an empty string
if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$
return true; return true;
} else { } else {
throw new SystemMessageException(getMessage("RSEF1300").makeSubstitution(FileSystemMessageUtil.getSourceLocation(status))); //$NON-NLS-1$ throw new SystemMessageException(getMessage("RSEF1300").makeSubstitution(FileSystemMessageUtil.getSourceLocation(status))); //$NON-NLS-1$

View file

@ -15,6 +15,7 @@
* {Name} (company) - description of contribution. * {Name} (company) - description of contribution.
* Xuan Chen (IBM) - [189041] incorrect file name after rename a file inside a zip file - DStore Windows * Xuan Chen (IBM) - [189041] incorrect file name after rename a file inside a zip file - DStore Windows
* Xuan Chen (IBM) - [187548] Editor shows incorrect file name after renaming file on Linux dstore * Xuan Chen (IBM) - [187548] Editor shows incorrect file name after renaming file on Linux dstore
* Kevin Doyle (IBM) - [191548] Various NPE fixes
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.services.dstore.files; package org.eclipse.rse.internal.services.dstore.files;
@ -85,6 +86,10 @@ public class DStoreHostFile implements IHostFile
public String getName() public String getName()
{ {
if (_element.getName() == null) {
// file was deleted on the host
return null;
}
String type = _element.getType(); String type = _element.getType();
if (type != null && type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)) if (type != null && type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
{ {
@ -122,6 +127,10 @@ public class DStoreHostFile implements IHostFile
public String getParentPath() public String getParentPath()
{ {
if (_element.getName() == null) {
// file was deleted on the host
return null;
}
String type = _element.getType(); String type = _element.getType();
if (type != null && type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR)) if (type != null && type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
{ {
@ -192,6 +201,10 @@ public class DStoreHostFile implements IHostFile
{ {
String parentPath = _element.getValue(); String parentPath = _element.getValue();
String name = _element.getName(); String name = _element.getName();
if (name == null) {
// file was deleted on the host
return false;
}
if (parentPath == null || if (parentPath == null ||
parentPath.length() == 0 || parentPath.length() == 0 ||
(name.length() == 0 && (parentPath.equals("/") || parentPath.endsWith(":\\")) || //$NON-NLS-1$ //$NON-NLS-2$ (name.length() == 0 && (parentPath.equals("/") || parentPath.endsWith(":\\")) || //$NON-NLS-1$ //$NON-NLS-2$
@ -210,9 +223,9 @@ public class DStoreHostFile implements IHostFile
public boolean isFile() public boolean isFile()
{ {
String type = _element.getType(); String type = _element.getType();
if (type != null && type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR) if (type != null && (type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILE_DESCRIPTOR)
|| type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR) || type.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
|| type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR)) || type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR)))
{ {
return true; return true;
} }