Bug 195709 - [Dstore][windows] Copying doesn't work when source path contains space
Summary: [Dstore][windows] Copying doesn't work when source path contains space
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Kevin Doyle CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-07-06 17:06 EDT by Kevin Doyle CLA
Modified: 2011-05-25 09:35 EDT (History)
1 user (show)

See Also:


Attachments
Only enQuote the source string once (1.62 KB, patch)
2007-07-08 21:04 EDT, Kevin Doyle CLA
no flags Details | Diff
Updated for latest changes to UniversalFileSystemMiner (1.62 KB, patch)
2007-07-09 14:33 EDT, Kevin Doyle CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2007-07-06 17:06:27 EDT
If you try and copy and paste a file/folder from a path that contains a space then the copy will fail.  The reason for this is that the xcopy command has the source directory with double quotes x2 around it.

Example Command it tries to do:

xcopy ""C:\Documents and Settings\webfacing\Desktop\source"" "C:\Documents a
nd Settings\webfacing\Desktop\patches\source" /S /E /K /Q /H /I /Y

If you try to type this in normally you get the error: Invalid number of parameters.

Steps to Reproduce:
1. Connect to a DStore Windows server.
2. Expand your My Home Filter.
3. Copy and Paste some file/folder from your My Home filter to another folder.
--> Error dialog appears saying Copy has failed.

-----------Enter bugs above this line-----------
TM 2.0 Testing
installation : eclipse-SDK-3.3
RSE install  : RSE 2.0
java.runtime : Sun 1.5.0_11-b03
os.name:     : Windows XP, Service Pack 2
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-07-06 17:54:36 EDT
Do you think you can come up with a patch? - Ideally, we should have some general utils for quoting.
Comment 2 Xuan Chen CLA 2007-07-06 22:21:16 EDT
Martin, since I've looked into a similar issue before, you could assign this bug to me.
And also (it is very strange) we could not debug the DStore server code in Kevin's machine.  The Java Remote Debugger just could not attach to the running DStore server, and we ended up adding quite a few of println statements in the DStore code.  Not sure if this has anything to do with using 1.6 of JRE?  Did anyone encounter this debugging issue before?
Comment 3 Kevin Doyle CLA 2007-07-07 23:37:10 EDT
Xuan I can take this one.  After taking a look at the source I see the problem.  We are making a src = enquote(src) call twice.  Unix and Windows both need it so it's done outside the if(_isWindows) and then done again inside the if(_isWindows).

For general quoting utilities in the code it calls enquote which is this:

	protected String enQuote(String s)
	{
		if(_isWindows) {
			return '"' + s + '"';
		} else {
			return PathUtility.enQuoteUnix(s);
		}
	}

We are already using org.eclipse.rse.services.clientserver.PathUtility to handle quoting for unix.  We could add an enQuoteWindows(s) that will put quotes around a string that isn't already quoted and also add an enQuote(s, boolean isWindows) that would just call the proper enQuoteWindows(Unix) function.

Since org.eclipse.rse.services.clientserver isn't internal should we open up a new bug enhancement for this for 3.0?
Comment 4 Kevin Doyle CLA 2007-07-08 21:04:16 EDT
Created attachment 73284 [details]
Only enQuote the source string once

Legal Message: I, Kevin Doyle, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 5 Kevin Doyle CLA 2007-07-09 14:33:36 EDT
Created attachment 73360 [details]
Updated for latest changes to UniversalFileSystemMiner
Comment 6 David McKnight CLA 2007-07-09 14:38:09 EDT
I've committed the fix to cvs.
Comment 7 Martin Oberhuber CLA 2007-07-10 07:09:26 EDT
Adding contributed kwd
Comment 8 Martin Oberhuber CLA 2007-07-10 07:31:13 EDT
(In reply to comment #3)
Thanks for the fix, it is good. Regarding the other issues brought up:

> We are already using org.eclipse.rse.services.clientserver.PathUtility to
> handle quoting for unix.  We could add an enQuoteWindows(s) that will put
> quotes around a string that isn't already quoted and also add an enQuote(s,
> boolean isWindows) that would just call the proper enQuoteWindows(Unix)
> function.

I do not want to promote quoting on windows too much since it doesn't really work too well. I think a better approach would be to avoid any shell command execution as well as any quoting, and have all the work done directly from Java.

Also, quoting on Windows is simple enough and functionality like "add quotes if they are not already there" just fosters programming errors (there should really be a prerequisite that quotes must be there or cannot be there).

Therefore, I'm against additional enQuoteWindows() API.
Comment 9 Kevin Doyle CLA 2007-07-15 17:39:33 EDT
Verified with I20070713-0605.