mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
[191548] fix: Deleting Read-Only directory removes it from view and displays no error
This commit is contained in:
parent
b32bc6595b
commit
acd2bd19c2
4 changed files with 96 additions and 61 deletions
|
@ -2123,7 +2123,7 @@ public class UniversalFileSystemMiner extends Miner {
|
|||
.getRegisteredHandler(new File(vpath
|
||||
.getContainingArchiveString()));
|
||||
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);
|
||||
return statusDone(status);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* {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;
|
||||
|
||||
|
@ -114,7 +115,7 @@ public class ArchiveQueryThread extends QueryThread {
|
|||
virtualPath = avp.getVirtualPart();
|
||||
fileobj = new File(rootPath);
|
||||
|
||||
if (fileobj.exists()) {
|
||||
if (fileobj.exists() && mgr.getVirtualObject(path).exists()) {
|
||||
|
||||
if (_foldersOnly) {
|
||||
children = mgr.getFolderContents(fileobj,
|
||||
|
@ -132,6 +133,20 @@ public class ArchiveQueryThread extends QueryThread {
|
|||
if (isCancelled())
|
||||
return;
|
||||
} 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$
|
||||
}
|
||||
}
|
||||
|
@ -226,63 +241,64 @@ public class ArchiveQueryThread extends QueryThread {
|
|||
// Check if the current Objects in the DataStore are valid... exist
|
||||
// on the remote host
|
||||
try {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < list.length; ++j) {
|
||||
if (isCancelled())
|
||||
return;
|
||||
|
||||
found = false;
|
||||
DataElement previousElement = (DataElement) filteredChildren
|
||||
.get(list[j].name);
|
||||
if (previousElement != null && !previousElement.isDeleted()) {
|
||||
// Type have to be equal as well
|
||||
String type = previousElement.getType();
|
||||
boolean isfile = !list[j].isDirectory;
|
||||
if (type
|
||||
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
|
||||
|| (type
|
||||
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR) && !isfile)) {
|
||||
filteredChildren.remove(list[j].name);
|
||||
found = true;
|
||||
if (list != null) {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < list.length; ++j) {
|
||||
if (isCancelled())
|
||||
return;
|
||||
|
||||
found = false;
|
||||
DataElement previousElement = (DataElement) filteredChildren
|
||||
.get(list[j].name);
|
||||
if (previousElement != null && !previousElement.isDeleted()) {
|
||||
// Type have to be equal as well
|
||||
String type = previousElement.getType();
|
||||
boolean isfile = !list[j].isDirectory;
|
||||
if (type
|
||||
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR)
|
||||
|| (type
|
||||
.equals(IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR) && !isfile)) {
|
||||
filteredChildren.remove(list[j].name);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
DataElement deObj = null;
|
||||
VirtualChild child = list[j];
|
||||
|
||||
if (found) {
|
||||
deObj = previousElement;
|
||||
}
|
||||
if (deObj == null) {
|
||||
if (child.isDirectory) {
|
||||
deObj = _dataStore
|
||||
.createObject(
|
||||
subject,
|
||||
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR,
|
||||
child.name);
|
||||
} else // file
|
||||
{
|
||||
deObj = _dataStore
|
||||
.createObject(
|
||||
subject,
|
||||
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR,
|
||||
child.name);
|
||||
DataElement deObj = null;
|
||||
VirtualChild child = list[j];
|
||||
|
||||
if (found) {
|
||||
deObj = previousElement;
|
||||
}
|
||||
|
||||
}
|
||||
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
|
||||
|
||||
if (deObj == null) {
|
||||
if (child.isDirectory) {
|
||||
deObj = _dataStore
|
||||
.createObject(
|
||||
subject,
|
||||
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR,
|
||||
child.name);
|
||||
} else // file
|
||||
{
|
||||
deObj = _dataStore
|
||||
.createObject(
|
||||
subject,
|
||||
IUniversalDataStoreConstants.UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR,
|
||||
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
|
||||
}
|
||||
// Object left over in the filteredChildren is no longer in the
|
||||
// system any more. Need to remove.
|
||||
Iterator myIterator = filteredChildren.keySet().iterator();
|
||||
|
|
|
@ -929,7 +929,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
DataElement de = getElementFor(remotePath);
|
||||
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_DELETE, monitor);
|
||||
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;
|
||||
} else {
|
||||
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);
|
||||
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;
|
||||
} else {
|
||||
throw new SystemMessageException(getMessage("RSEF1300").makeSubstitution(FileSystemMessageUtil.getSourceLocation(status))); //$NON-NLS-1$
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* {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) - [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;
|
||||
|
@ -85,6 +86,10 @@ public class DStoreHostFile implements IHostFile
|
|||
|
||||
public String getName()
|
||||
{
|
||||
if (_element.getName() == null) {
|
||||
// file was deleted on the host
|
||||
return null;
|
||||
}
|
||||
String type = _element.getType();
|
||||
if (type != null && type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
|
||||
{
|
||||
|
@ -122,6 +127,10 @@ public class DStoreHostFile implements IHostFile
|
|||
|
||||
public String getParentPath()
|
||||
{
|
||||
if (_element.getName() == null) {
|
||||
// file was deleted on the host
|
||||
return null;
|
||||
}
|
||||
String type = _element.getType();
|
||||
if (type != null && type.equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
|
||||
{
|
||||
|
@ -192,6 +201,10 @@ public class DStoreHostFile implements IHostFile
|
|||
{
|
||||
String parentPath = _element.getValue();
|
||||
String name = _element.getName();
|
||||
if (name == null) {
|
||||
// file was deleted on the host
|
||||
return false;
|
||||
}
|
||||
if (parentPath == null ||
|
||||
parentPath.length() == 0 ||
|
||||
(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()
|
||||
{
|
||||
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_ARCHIVE_FILE_DESCRIPTOR))
|
||||
|| type.equals(IUniversalDataStoreConstants.UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue