Bug 201790 - [dnd] Copy and Paste across connections to a Drive doesn't work
Summary: [dnd] Copy and Paste across connections to a Drive doesn't work
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Xuan Chen CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-30 16:13 EDT by Kevin Doyle CLA
Modified: 2007-09-13 11:08 EDT (History)
2 users (show)

See Also:
dmcknigh: review+


Attachments
fix for the bug (1.61 KB, patch)
2007-09-05 18:08 EDT, Xuan Chen CLA
xuanchen: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.