mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 18:05:33 +02:00
[196211] Kevin's patch for Move a folder to a directory that contains a folder by that name errors
This commit is contained in:
parent
daef342bea
commit
9ca712e072
3 changed files with 61 additions and 30 deletions
|
@ -18,6 +18,7 @@
|
||||||
* Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root
|
* Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root
|
||||||
* Xuan Chen (IBM) - [191280] [dstore] Expand fails for folder "/folk" with 3361 children
|
* Xuan Chen (IBM) - [191280] [dstore] Expand fails for folder "/folk" with 3361 children
|
||||||
* Kevin Doyle (IBM) - [195709] Windows Copying doesn't work when path contains space
|
* Kevin Doyle (IBM) - [195709] Windows Copying doesn't work when path contains space
|
||||||
|
* Kevin Doyle (IBM) - [196211] DStore Move tries rename if that fails copy/delete
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.dstore.universal.miners;
|
package org.eclipse.rse.dstore.universal.miners;
|
||||||
|
@ -962,8 +963,7 @@ public class UniversalFileSystemMiner extends Miner {
|
||||||
public DataElement handleRename(DataElement subject, DataElement status) {
|
public DataElement handleRename(DataElement subject, DataElement status) {
|
||||||
File fileoldname = new File(subject.getAttribute(DE.A_VALUE)
|
File fileoldname = new File(subject.getAttribute(DE.A_VALUE)
|
||||||
+ File.separatorChar + subject.getName());
|
+ File.separatorChar + subject.getName());
|
||||||
File filerename = new File(subject.getAttribute(DE.A_VALUE)
|
File filerename = new File(subject.getAttribute(DE.A_SOURCE));
|
||||||
+ File.separatorChar + subject.getAttribute(DE.A_SOURCE));
|
|
||||||
|
|
||||||
// System.out.println(ArchiveHandlerManager.isVirtual(fileoldname
|
// System.out.println(ArchiveHandlerManager.isVirtual(fileoldname
|
||||||
// .getAbsolutePath()));
|
// .getAbsolutePath()));
|
||||||
|
|
|
@ -960,9 +960,21 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
|
public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
String remotePath = remoteParent + getSeparator(remoteParent) + oldName;
|
String oldPath, newPath = null;
|
||||||
DataElement de = getElementFor(remotePath);
|
// if remoteParent is null or empty then we are doing a move
|
||||||
de.setAttribute(DE.A_SOURCE, newName);
|
if (remoteParent == null || remoteParent == "") //$NON-NLS-1$
|
||||||
|
{
|
||||||
|
oldPath = oldName;
|
||||||
|
newPath = newName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oldPath = remoteParent + getSeparator(remoteParent) + oldName;
|
||||||
|
newPath = remoteParent + getSeparator(remoteParent) + newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataElement de = getElementFor(oldPath);
|
||||||
|
de.setAttribute(DE.A_SOURCE, newPath);
|
||||||
|
|
||||||
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor);
|
DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor);
|
||||||
|
|
||||||
|
@ -983,26 +995,42 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean moveByCopy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
|
{
|
||||||
|
if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
|
||||||
|
{
|
||||||
|
return delete(srcParent, srcName, monitor);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
|
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
// String src = srcParent + getSeparator(srcParent) + srcName;
|
String src = srcParent + getSeparator(srcParent) + srcName;
|
||||||
// String tgt = tgtParent + getSeparator(tgtParent) + tgtName;
|
String tgt = tgtParent + getSeparator(tgtParent) + tgtName;
|
||||||
// boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt);
|
boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt);
|
||||||
//if (isVirtual || isArchive)
|
boolean isArchive = ArchiveHandlerManager.getInstance().isRegisteredArchive(tgt);
|
||||||
|
if (isVirtual || isArchive)
|
||||||
{
|
{
|
||||||
if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
|
return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boolean movedOk = false;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
movedOk = rename("", src, tgt, monitor); //$NON-NLS-1$
|
||||||
{
|
|
||||||
delete(srcParent, srcName, monitor);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
catch (SystemMessageException e)
|
||||||
|
{
|
||||||
|
return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
||||||
|
}
|
||||||
|
// movedOk should never be false otherwise the last DataElement status was null
|
||||||
|
if (!movedOk)
|
||||||
|
{
|
||||||
|
movedOk = moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
|
||||||
|
}
|
||||||
|
return movedOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
* Kevin Doyle (IBM) - [182221] Throwing Proper Exceptions on create file/folder
|
* Kevin Doyle (IBM) - [182221] Throwing Proper Exceptions on create file/folder
|
||||||
* Xuan Chen (IBM) - Fix 189487 - copy and paste a folder did not work - workbench hang
|
* Xuan Chen (IBM) - Fix 189487 - copy and paste a folder did not work - workbench hang
|
||||||
* David McKnight (IBM) - [192705] Exception needs to be thrown when rename fails
|
* David McKnight (IBM) - [192705] Exception needs to be thrown when rename fails
|
||||||
|
* Kevin Doyle (IBM) - [196211] Move a folder to a directory that contains a folder by that name errors
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.local.files;
|
package org.eclipse.rse.internal.services.local.files;
|
||||||
|
@ -1047,28 +1048,30 @@ public class LocalFileService extends AbstractFileService implements IFileServic
|
||||||
{
|
{
|
||||||
File sourceFolderOrFile = new File(srcParent, srcName);
|
File sourceFolderOrFile = new File(srcParent, srcName);
|
||||||
File targetFolder = new File(tgtParent, tgtName);
|
File targetFolder = new File(tgtParent, tgtName);
|
||||||
|
boolean movedOk = false;
|
||||||
boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(sourceFolderOrFile.getAbsolutePath());
|
boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(sourceFolderOrFile.getAbsolutePath());
|
||||||
boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(targetFolder.getAbsolutePath());
|
boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(targetFolder.getAbsolutePath());
|
||||||
boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(targetFolder);
|
boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(targetFolder);
|
||||||
if (sourceIsVirtual || targetIsVirtual || targetIsArchive)
|
if (!sourceIsVirtual && !targetIsVirtual && !targetIsArchive)
|
||||||
/* DKM
|
/* DKM
|
||||||
* we shouldn't be moving archives like virtuals
|
* we shouldn't be moving archives like virtuals
|
||||||
*|| ArchiveHandlerManager.getInstance().isRegisteredArchive(newName)
|
*|| ArchiveHandlerManager.getInstance().isRegisteredArchive(newName)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
|
|
||||||
{
|
|
||||||
return delete(srcParent, srcName, monitor);
|
|
||||||
}
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
File fileToMove = new File(srcParent, srcName);
|
File fileToMove = new File(srcParent, srcName);
|
||||||
File newFile = new File(tgtParent, tgtName);
|
File newFile = new File(tgtParent, tgtName);
|
||||||
return fileToMove.renameTo(newFile);
|
movedOk = fileToMove.renameTo(newFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!movedOk)
|
||||||
|
{
|
||||||
|
if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
|
||||||
|
{
|
||||||
|
movedOk = delete(srcParent, srcName, monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return movedOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue