View | Details | Raw Unified | Return to bug 196211 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rse/internal/services/local/files/LocalFileService.java (-9 / +12 lines)
Lines 17-22 Link Here
17
 * Kevin Doyle (IBM) - [182221] Throwing Proper Exceptions on create file/folder
17
 * Kevin Doyle (IBM) - [182221] Throwing Proper Exceptions on create file/folder
18
 * Xuan Chen        (IBM)        - Fix 189487 - copy and paste a folder did not work - workbench hang
18
 * Xuan Chen        (IBM)        - Fix 189487 - copy and paste a folder did not work - workbench hang
19
 * David McKnight   (IBM)        - [192705] Exception needs to be thrown when rename fails
19
 * David McKnight   (IBM)        - [192705] Exception needs to be thrown when rename fails
20
 * Kevin Doyle (IBM) - [196211] Move a folder to a directory that contains a folder by that name errors
20
 ********************************************************************************/
21
 ********************************************************************************/
21
22
22
package org.eclipse.rse.internal.services.local.files;
23
package org.eclipse.rse.internal.services.local.files;
Lines 1047-1074 Link Here
1047
	{
1048
	{
1048
		File sourceFolderOrFile = new File(srcParent, srcName);
1049
		File sourceFolderOrFile = new File(srcParent, srcName);
1049
		File targetFolder = new File(tgtParent, tgtName);
1050
		File targetFolder = new File(tgtParent, tgtName);
1051
		boolean movedOk = false;
1050
		boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(sourceFolderOrFile.getAbsolutePath());
1052
		boolean sourceIsVirtual = ArchiveHandlerManager.isVirtual(sourceFolderOrFile.getAbsolutePath());
1051
		boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(targetFolder.getAbsolutePath());
1053
		boolean targetIsVirtual = ArchiveHandlerManager.isVirtual(targetFolder.getAbsolutePath());
1052
		boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(targetFolder);
1054
		boolean targetIsArchive = ArchiveHandlerManager.getInstance().isArchive(targetFolder);
1053
		if (sourceIsVirtual || targetIsVirtual || targetIsArchive)
1055
		if (!sourceIsVirtual && !targetIsVirtual && !targetIsArchive)
1054
				/* DKM
1056
				/* DKM
1055
				 * we shouldn't be moving archives like virtuals
1057
				 * we shouldn't be moving archives like virtuals
1056
				 *|| ArchiveHandlerManager.getInstance().isRegisteredArchive(newName)
1058
				 *|| ArchiveHandlerManager.getInstance().isRegisteredArchive(newName)
1057
				 *
1059
				 *
1058
				 */
1060
				 */
1059
		{
1061
		{
1062
			File fileToMove = new File(srcParent, srcName);
1063
			File newFile = new File(tgtParent, tgtName);
1064
			movedOk = fileToMove.renameTo(newFile);
1065
		}
1066
		
1067
		if (!movedOk)
1068
		{	
1060
			if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
1069
			if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
1061
			{
1070
			{
1062
				return delete(srcParent, srcName, monitor);
1071
				movedOk = delete(srcParent, srcName, monitor);
1063
			}
1072
			}
1064
			else return false;
1065
		}
1066
		else
1067
		{
1068
			File fileToMove = new File(srcParent, srcName);
1069
			File newFile = new File(tgtParent, tgtName);
1070
			return fileToMove.renameTo(newFile);
1071
		}
1073
		}
1074
		return movedOk;
1072
	}
1075
	}
1073
1076
1074
1077
(-)miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java (-2 / +2 lines)
Lines 18-23 Link Here
18
 * Xuan Chen (IBM)        - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root
18
 * Xuan Chen (IBM)        - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root
19
 * Xuan Chen (IBM)        - [191280] [dstore] Expand fails for folder "/folk" with 3361 children
19
 * Xuan Chen (IBM)        - [191280] [dstore] Expand fails for folder "/folk" with 3361 children
20
 * Kevin Doyle (IBM) - [195709] Windows Copying doesn't work when path contains space
20
 * Kevin Doyle (IBM) - [195709] Windows Copying doesn't work when path contains space
21
 * Kevin Doyle (IBM) - [196211] DStore Move tries rename if that fails copy/delete
21
 *******************************************************************************/
22
 *******************************************************************************/
22
23
23
package org.eclipse.rse.dstore.universal.miners;
24
package org.eclipse.rse.dstore.universal.miners;
Lines 962-969 Link Here
962
	public DataElement handleRename(DataElement subject, DataElement status) {
963
	public DataElement handleRename(DataElement subject, DataElement status) {
963
		File fileoldname = new File(subject.getAttribute(DE.A_VALUE)
964
		File fileoldname = new File(subject.getAttribute(DE.A_VALUE)
964
				+ File.separatorChar + subject.getName());
965
				+ File.separatorChar + subject.getName());
965
		File filerename = new File(subject.getAttribute(DE.A_VALUE)
966
		File filerename = new File(subject.getAttribute(DE.A_SOURCE));
966
				+ File.separatorChar + subject.getAttribute(DE.A_SOURCE));
967
967
968
	//	System.out.println(ArchiveHandlerManager.isVirtual(fileoldname
968
	//	System.out.println(ArchiveHandlerManager.isVirtual(fileoldname
969
		//		.getAbsolutePath()));
969
		//		.getAbsolutePath()));
(-)src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java (-20 / +48 lines)
Lines 960-968 Link Here
960
960
961
	public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
961
	public boolean rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException
962
	{
962
	{
963
		String remotePath = remoteParent + getSeparator(remoteParent) + oldName;
963
		String oldPath, newPath = null;
964
		DataElement de = getElementFor(remotePath);
964
 		// if remoteParent is null or empty then we are doing a move
965
		de.setAttribute(DE.A_SOURCE, newName);
965
 		if (remoteParent == null || remoteParent == "") //$NON-NLS-1$
966
 		{
967
 			oldPath = oldName;
968
 		 	newPath = newName;
969
 		}
970
 		else
971
 		{
972
 			 oldPath = remoteParent + getSeparator(remoteParent) + oldName;
973
 			 newPath = remoteParent + getSeparator(remoteParent) + newName;
974
 		}
975
 		
976
 		DataElement de = getElementFor(oldPath);
977
 		de.setAttribute(DE.A_SOURCE, newPath);
966
		
978
		
967
		DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor);
979
		DataElement status = dsStatusCommand(de, IUniversalDataStoreConstants.C_RENAME, monitor);
968
980
Lines 983-1008 Link Here
983
		return retVal;
995
		return retVal;
984
	}
996
	}
985
997
998
	protected boolean moveByCopy(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
999
	{
1000
		if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
1001
	 	{
1002
			return delete(srcParent, srcName, monitor);
1003
	 	}
1004
	 	return false;
1005
	}
1006
	
986
	public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
1007
	public boolean move(String srcParent, String srcName, String tgtParent, String tgtName, IProgressMonitor monitor) throws SystemMessageException
987
	{
1008
	{
988
//		String src = srcParent + getSeparator(srcParent) + srcName;
1009
		String src = srcParent + getSeparator(srcParent) + srcName;
989
//		String tgt = tgtParent + getSeparator(tgtParent) + tgtName;
1010
		String tgt = tgtParent + getSeparator(tgtParent) + tgtName;
990
//		boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt);
1011
		boolean isVirtual = ArchiveHandlerManager.isVirtual(src) || ArchiveHandlerManager.isVirtual(tgt);
991
		//if (isVirtual || isArchive)
1012
		boolean isArchive = ArchiveHandlerManager.getInstance().isRegisteredArchive(tgt);
992
		{
1013
		if (isVirtual || isArchive)
993
			if (copy(srcParent, srcName, tgtParent, tgtName, monitor))
1014
		{
994
			{
1015
			return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
995
				try
1016
		}
996
				{
1017
		else
997
					delete(srcParent, srcName, monitor);
1018
		{
998
				}
1019
			boolean movedOk = false;
999
				catch (Exception e)
1020
			try
1000
				{
1021
			{
1001
					return false;
1022
				movedOk = rename("", src, tgt, monitor); //$NON-NLS-1$
1002
				}
1003
				return true;
1004
			}
1023
			}
1005
			return false;
1024
			catch (SystemMessageException e)
1025
			{
1026
				return moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
1027
			}
1028
			// movedOk should never be false otherwise the last DataElement status was null
1029
			if (!movedOk)
1030
			{
1031
				movedOk = moveByCopy(srcParent, srcName, tgtParent, tgtName, monitor);
1032
			}
1033
			return movedOk;
1006
		}
1034
		}
1007
1035
1008
/*
1036
/*

Return to bug 196211