Bug 201790

Summary: [dnd] Copy and Paste across connections to a Drive doesn't work
Product: [Tools] Target Management Reporter: Kevin Doyle <kjdoyle>
Component: RSEAssignee: Xuan Chen <xuanchen>
Status: CLOSED FIXED QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P2 CC: dmcknigh, xuanchen
Version: 2.0Flags: dmcknigh: review+
Target Milestone: 2.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
fix for the bug xuanchen: review+

Description Kevin Doyle CLA 2007-08-30 16:13:29 EDT
Copying and Pasting a file from one connection to a Local drive doesn't work.  Copy and Paste within Local to a Drive works though.

Steps to Reproduce:
1. Create a connection.
2. Copy some file from that connection.
3. Go to your C:\ and try to paste.
--> No error is shown, but the paste doesn't work.

-----------Enter bugs above this line-----------
TM 2.0.1 Testing
installation : eclipse-SDK-3.3
RSE install  : Dev Driver - 
java.runtime : Sun 1.5.0_11-b03
os.name:     : Windows XP, Service Pack 2
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-09-03 11:44:26 EDT
That's an ugly loss of functionality. Dave can you check this?
Comment 2 Xuan Chen CLA 2007-09-05 01:10:14 EDT
I could see the following NPE on the console of my first workspace:

java.lang.NullPointerException
	at org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility.copyWorkspaceResourcesToRemote(UniversalFileTransferUtility.java:1158)
	at org.eclipse.rse.internal.files.ui.view.SystemViewRemoteFileAdapter.doDrop(SystemViewRemoteFileAdapter.java:1777)
	at org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable.transferRSEResources(SystemDNDTransferRunnable.java:214)
	at org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable.runInWorkspace(SystemDNDTransferRunnable.java:589)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


The reason is in UniversalFileTransferUtility#copyWorkspaceResourcesToRemote() method, we do the following:

boolean isTargetArchive = targetFolder.isArchive();
		if (isTargetArchive && !targetFolder.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement()) return null;
		StringBuffer newPathBuf = new StringBuffer(targetFolder.getAbsolutePath());
		if (isTargetArchive)
		{
			newPathBuf.append(ArchiveHandlerManager.VIRTUAL_SEPARATOR);
		}
		else
		{
			newPathBuf.append(targetFolder.getSeparatorChar());
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		}

In the case where the target folder is not a drive, targetFolder.getAbsolutePath() returns the full path without the last separator.
But in the case of a drive, it returns "C:\\"

So the new path with becomes "C:\\\\", which does not exist.

To fix it, we need to check if the newPathBuf already ends with the separatorChar.  If yes, we don't need to append it.



Comment 3 Xuan Chen CLA 2007-09-05 01:11:44 EDT
The other thing I noticed is that copy a folder from one connection to an archive file in a different connection does not work.  But that is the different issue.  I will open a separate bug for it.
Comment 4 Xuan Chen CLA 2007-09-05 18:08:21 EDT
Created attachment 77759 [details]
fix for the bug

I put in the following fix:

Check if the full path of the target folder already ends with the separator character of the file subsystem.  If no, we will append the separator to the target folder path.
Comment 5 David McKnight CLA 2007-09-06 12:10:32 EDT
The fix looks good.
Comment 6 Xuan Chen CLA 2007-09-06 15:19:29 EDT
I committed the fix.
Comment 7 Kevin Doyle CLA 2007-09-13 11:08:01 EDT
Verified fixed with 2.0.1RC1.