maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1174063 - in /maven/wagon/trunk/wagon-providers: wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ wagon-ssh-external/src/test/java/org/apache/mav...
Date Thu, 22 Sep 2011 11:22:44 GMT
Author: olamy
Date: Thu Sep 22 11:22:43 2011
New Revision: 1174063

URL: http://svn.apache.org/viewvc?rev=1174063&view=rev
Log:
[WAGON-312] Cannot download folders with spaces via SCP

Added:
    maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/resources/dummy.txt
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/dummy.txt
Modified:
    maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java?rev=1174063&r1=1174062&r2=1174063&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
Thu Sep 22 11:22:43 2011
@@ -20,12 +20,15 @@ package org.apache.maven.wagon.providers
  */
 
 import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.repository.Repository;
 import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -104,5 +107,62 @@ public abstract class AbstractEmbeddedSc
         return false;
     }
 
+    public void testWithSpaces()
+        throws Exception
+    {
+        String dir = "foo   test";
+        File spaceDirectory = new File( TestData.getRepoPath(), dir );
+        if ( spaceDirectory.exists() )
+        {
+            FileUtils.deleteDirectory( spaceDirectory );
+        }
+        spaceDirectory.mkdirs();
+
+        String subDir = "foo bar";
+        File sub = new File( spaceDirectory, subDir );
+        if ( sub.exists() )
+        {
+            FileUtils.deleteDirectory( sub );
+        }
+        sub.mkdirs();
+
+        File dummy = new File( "src/test/resources/dummy.txt" );
+        FileUtils.copyFileToDirectory( dummy, sub );
+
+        String url = getTestRepositoryUrl() + "/" + dir;
+        Repository repo = new Repository( "foo", url );
+        Wagon wagon = getWagon();
+        wagon.connect( repo );
+        List<String> files = wagon.getFileList( subDir );
+        assertNotNull( files );
+        assertEquals( 1, files.size() );
+        assertTrue( files.contains( "dummy.txt" ) );
+
+        wagon.put( new File( "src/test/resources/dummy.txt" ), subDir + "/newdummy.txt" );
+
+        files = wagon.getFileList( subDir );
+        assertNotNull( files );
+        assertEquals( 2, files.size() );
+        assertTrue( files.contains( "dummy.txt" ) );
+        assertTrue( files.contains( "newdummy.txt" ) );
+
+        File sourceWithSpace = new File( "target/directory with spaces" );
+        if ( sourceWithSpace.exists() )
+        {
+            FileUtils.deleteDirectory( sourceWithSpace );
+        }
+        File resources = new File( "src/test/resources" );
+
+        FileUtils.copyDirectory( resources, sourceWithSpace );
+
+        wagon.putDirectory( sourceWithSpace, "target with spaces" );
+
+        files = wagon.getFileList( "target with spaces" );
+
+        assertNotNull( files );
+        assertTrue( files.contains( "dummy.txt" ) );
+        assertFalse( files.contains( "newdummy.txt" ) );
+        assertTrue( files.contains( "log4j.xml" ) );
+    }
 
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java?rev=1174063&r1=1174062&r2=1174063&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java
Thu Sep 22 11:22:43 2011
@@ -37,7 +37,12 @@ public class TestData
 
     public static String getTestRepositoryUrl( int port )
     {
-        return "scp://" + getHostname() + ":" + port + getTempDirectory() + "/wagon-ssh-test/"
+ getUserName();
+        return "scp://" + getHostname() + ":" + port + getRepoPath();
+    }
+
+    public static String getRepoPath()
+    {
+        return getTempDirectory() + "/wagon-ssh-test/" + getUserName();
     }
 
     public static String getUserName()

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java?rev=1174063&r1=1174062&r2=1174063&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
Thu Sep 22 11:22:43 2011
@@ -67,7 +67,6 @@ public class LSParser
     public List<String> parseFiles( String rawLS )
         throws TransferFailedException
     {
-        System.out.println( "LSParser raw : " + rawLS );
         List<String> ret = new ArrayList<String>();
         try
         {

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java?rev=1174063&r1=1174062&r2=1174063&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
Thu Sep 22 11:22:43 2011
@@ -221,7 +221,8 @@ public class ScpHelper
                 }
             }
 
-            String mkdirCmd = "mkdir -p " + path;
+            //String mkdirCmd = "mkdir -p " + path;
+            String mkdirCmd = "mkdir -p \"" + path + "\"";
 
             executor.executeCommand( mkdirCmd );
         }
@@ -249,8 +250,9 @@ public class ScpHelper
 
         try
         {
-            executor.executeCommand(
-                "cd " + path + "; unzip -q -o " + zipFile.getName() + "; rm -f " + zipFile.getName()
);
+            //executor.executeCommand(
+            //    "cd " + path + "; unzip -q -o " + zipFile.getName() + "; rm -f " + zipFile.getName()
);
+            executor.executeCommand( "cd \"" + path + "\"; unzip -q -o \"" + zipFile.getName()
+ "\"; rm -f \"" + zipFile.getName() + "\"" );
 
             zipFile.delete();
 
@@ -258,12 +260,14 @@ public class ScpHelper
 
             if ( permissions != null && permissions.getGroup() != null )
             {
-                executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " " + path
);
+                //executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " " +
path );
+                executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " \"" +
path + "\"" );
             }
 
             if ( permissions != null && permissions.getFileMode() != null )
             {
-                executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " " +
path );
+                //executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " "
+ path );
+                executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " \""
+ path + "\"" );
             }
         }
         catch ( CommandExecutionException e )
@@ -278,7 +282,8 @@ public class ScpHelper
         try
         {
             String path = getPath( repository.getBasedir(), destinationDirectory );
-            Streams streams = executor.executeCommand( "ls -FlA " + path, false );
+            //Streams streams = executor.executeCommand( "ls -FlA " + path, false );
+            Streams streams = executor.executeCommand( "ls -FlA \"" + path + "\"", false
);
 
             List<String> ret = new LSParser().parseFiles( streams.getOut() );
             if ( ret == null || ret.isEmpty() )
@@ -310,7 +315,8 @@ public class ScpHelper
         try
         {
             String path = getPath( repository.getBasedir(), resourceName );
-            executor.executeCommand( "ls " + path, false );
+            //executor.executeCommand( "ls " + path, false );
+            executor.executeCommand( "ls \"" + path + "\"" );
 
             // Parsing of output not really needed.  As a failed ls results in a
             // CommandExectionException on the 'ls' command.
@@ -338,7 +344,8 @@ public class ScpHelper
             }
         }
 
-        String mkdirCmd = "mkdir -p " + path;
+        //String mkdirCmd = "mkdir -p " + path;
+        String mkdirCmd = "mkdir -p \"" + path + "\"";
 
         if ( umaskCmd != null )
         {

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java?rev=1174063&r1=1174062&r2=1174063&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
Thu Sep 22 11:22:43 2011
@@ -24,10 +24,13 @@ import org.apache.maven.wagon.Streams;
 import org.apache.maven.wagon.Wagon;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonWithKeyTest;
+import org.apache.maven.wagon.providers.ssh.TestData;
+import org.apache.maven.wagon.repository.Repository;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
 
 import java.io.File;
+import java.util.List;
 
 /**
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
@@ -104,4 +107,6 @@ public class EmbeddedScpExternalWagonWit
     }
 
 
+
+
 }

Added: maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/resources/dummy.txt
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/resources/dummy.txt?rev=1174063&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/resources/dummy.txt (added)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/test/resources/dummy.txt Thu
Sep 22 11:22:43 2011
@@ -0,0 +1 @@
+dummy file with fake content.
\ No newline at end of file

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java?rev=1174063&r1=1174062&r2=1174063&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
Thu Sep 22 11:22:43 2011
@@ -76,7 +76,8 @@ public class ScpWagon
     {
         if ( permissions != null && permissions.getGroup() != null )
         {
-            executeCommand( "chgrp -f " + permissions.getGroup() + " " + getPath( basedir,
resource.getName() ) );
+            //executeCommand( "chgrp -f " + permissions.getGroup() + " " + getPath( basedir,
resource.getName() ) );
+            executeCommand( "chgrp -f " + permissions.getGroup() + " \"" + getPath( basedir,
resource.getName() ) + "\"" );
         }
     }
 
@@ -217,7 +218,8 @@ public class ScpWagon
         Resource resource = inputData.getResource();
 
         String path = getPath( getRepository().getBasedir(), resource.getName() );
-        String cmd = "scp -p -f " + path;
+        //String cmd = "scp -p -f " + path;
+        String cmd = "scp -p -f \"" + path + "\"";
 
         fireTransferDebug( "Executing command: " + cmd );
 

Added: maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/dummy.txt
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/dummy.txt?rev=1174063&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/dummy.txt (added)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/test/resources/dummy.txt Thu Sep 22 11:22:43
2011
@@ -0,0 +1 @@
+dummy file with fake content.
\ No newline at end of file



Mime
View raw message