mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 07:35:24 +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) - [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) - [196211] DStore Move tries rename if that fails copy/delete
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.dstore.universal.miners;
|
||||
|
@ -962,8 +963,7 @@ public class UniversalFileSystemMiner extends Miner {
|
|||
public DataElement handleRename(DataElement subject, DataElement status) {
|
||||
File fileoldname = new File(subject.getAttribute(DE.A_VALUE)
|
||||
+ File.separatorChar + subject.getName());
|
||||
File filerename = new File(subject.getAttribute(DE.A_VALUE)
|
||||
+ File.separatorChar + subject.getAttribute(DE.A_SOURCE));
|
||||
File filerename = new File(subject.getAttribute(DE.A_SOURCE));
|
||||
|
||||
// System.out.println(ArchiveHandlerManager.isVirtual(fileoldname
|
||||
// .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
|
||||
{
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + oldName;
|
||||
DataElement de = getElementFor(remotePath);
|
||||
de.setAttribute(DE.A_SOURCE, newName);
|
||||
String oldPath, newPath = null;
|
||||
// if remoteParent is null or empty then we are doing a move
|
||||
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);
|
||||
|
||||
|
@ -983,26 +995,42 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
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
|
||||
{
|
||||
// String src = srcParent + getSeparator(srcParent) + srcName;
|
||||
// String tgt = tgtParent + getSeparator(tgtParent) + tgtName;
|
||||
// boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt);
|
||||
//if (isVirtual || isArchive)
|
||||
String src = srcParent + getSeparator(srcParent) + srcName;
|
||||
String tgt = tgtParent + getSeparator(tgtParent) + tgtName;
|
||||
boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt);
|
||||
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
|
||||
{
|
||||
delete(srcParent, srcName, monitor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
movedOk = rename("", src, tgt, monitor); //$NON-NLS-1$
|
||||
}
|
||||
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
|
||||
* 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
|
||||
* 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;
|
||||
|
@ -1047,28 +1048,30 @@ public class LocalFileService extends AbstractFileService implements IFileServic
|
|||
{
|
||||
File sourceFolderOrFile = new File(srcParent, srcName);
|
||||
File targetFolder = new File(tgtParent, tgtName);
|
||||
boolean movedOk = false;
|
||||
boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(sourceFolderOrFile.getAbsolutePath());
|
||||
boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(targetFolder.getAbsolutePath());
|
||||
boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(targetFolder);
|
||||
if (sourceIsVirtual || targetIsVirtual || targetIsArchive)
|
||||
if (!sourceIsVirtual && !targetIsVirtual && !targetIsArchive)
|
||||
/* DKM
|
||||
* we shouldn't be moving archives like virtuals
|
||||
*|| 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 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