Closed kopaka closed 8 years ago
Hello. I'm unclear where the single quotes are coming from. If they're coming from the command-line, how do you feel about trimming sooner (main, or doCopy for example) and using %q
in the script formatting?
https://play.golang.org/p/J8oqAmbgh_
We've not got a dedicated place to do path cleansing, but I imagine it would be good keep it out of the PowerShell.
The single quotes come from a call to winPath()
, in path.go. winPath()
is invoked in each call to doCopy()
. For example: doCopy(fs.client, fs.config, src, winPath(toPath))
.
The single quotes do not appear to cause an issue anywhere in the code, except for GetFullPath()
. Consequently, it is probably acceptable to 'clean' the path only immediately before the call to GetFullPath()
.
That said, I do not see any issue with your implementation, and so cleaning the path in doCopy()
itself should be fine. The key is that the single quotes are removed before the call to GetFullPath()
. How (or even when) that is accomplished is likely immaterial.
Thanks for taking the time to highlight the problem. I've implemented my idea in a branch: 4f3734d1ca91247c231348ae054189330422d1cc.
But I'm not in a position to test it right now. Since it's more broad and risky than this PR, I'm gratefully accepting it now. Cheers.
Thanks, @dylanmei. Happy to have helped! :)
When
toPath
contains one or more spaces, it is wrapped in single quotes. IftoPath
also begins with a volume identifier (e.g.C:
), the opening single quote offsets the colon (:
) by one position in the string. This results in a NotSupportedException exception being thrown during the call toGetFullPath()
.The solution is to always trim single quotes from
toPath
before the call toGetFullPath()
is made.