Index: wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
===================================================================
--- wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java	(revision 409269)
+++ wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,6 +51,8 @@
 public abstract class AbstractWagon
     implements Wagon
 {
+    private static final String TEMP_FILE_EXTENSION = ".tmp.file";
+
     protected static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
 
     protected Repository repository;
@@ -706,4 +708,27 @@
     {
         this.interactive = interactive;
     }
+
+    /**
+     * Get the temporary name for a given resource
+     * 
+     * @param resource
+     * @return a temporary resource name 
+     */
+    protected String getTempResourceName( Resource resource )
+    {
+        return getTempResourceName( resource.getName() );
+    }
+
+    /**
+     * Get the temporary name for a resource name
+     * 
+     * @param resourceName
+     * @return a temporary resource name 
+     */
+    protected String getTempResourceName( String resourceName )
+    {
+        return resourceName + TEMP_FILE_EXTENSION;
+    }
+
 }
Index: wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
===================================================================
--- wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java	(revision 409022)
+++ wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,9 +38,24 @@
     //
     // ----------------------------------------------------------------------
 
+    /**
+     * Create and set the inputStream field of the inputData parameter so we can call correctly {@link InputData#getInputStream()}.
+     * Used in the GET method.
+     * 
+     * @param inputData
+     * @throws TransferFailedException
+     * @throws ResourceDoesNotExistException
+     */
     public abstract void fillInputData( InputData inputData )
         throws TransferFailedException, ResourceDoesNotExistException;
 
+    /**
+     * Create and set the outputStream field of the outputData parameter so we can call correctly {@link OutputData#getOutputStream()}.
+     * Used in the PUT method.
+     * 
+     * @param outputData
+     * @throws TransferFailedException
+     */
     public abstract void fillOutputData( OutputData outputData )
         throws TransferFailedException;
 
Index: wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java
===================================================================
--- wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java	(revision 409022)
+++ wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon.providers.file;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@
     {
         Resource resource = outputData.getResource();
 
-        File file = new File( getRepository().getBasedir(), resource.getName() );
+        File file = new File( getRepository().getBasedir(), getTempResourceName( resource ) );
 
         createParentDirectories( file );
 
@@ -133,4 +133,25 @@
             throw new TransferFailedException( "Error copying directory structure", e );
         }
     }
+
+    /**
+     * Transfer and rename temp file to final 
+     */
+    protected void transfer( Resource resource, File source, OutputStream output, boolean closeOutput )
+        throws TransferFailedException
+    {
+        super.transfer( resource, source, output, closeOutput );
+
+        File tempFile = new File( getRepository().getBasedir(), getTempResourceName( resource ) );
+
+        File finalFile = new File( getRepository().getBasedir(), resource.getName() );
+        
+        if ( finalFile.exists() )
+        {
+            finalFile.delete();
+        }
+
+        tempFile.renameTo( finalFile );
+    }
+
 }
Index: wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
===================================================================
--- wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java	(revision 409022)
+++ wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon.providers.ftp;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.commons.net.ftp.FTPFile;
 import org.apache.commons.net.ftp.FTPReply;
+import org.apache.commons.net.ftp.FTPCommand;
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.InputData;
 import org.apache.maven.wagon.OutputData;
@@ -230,7 +231,7 @@
                     "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" );
             }
 
-            String[] dirs = PathUtils.dirnames( resource.getName() );
+            String[] dirs = PathUtils.dirnames( getTempResourceName( resource ) );
 
             for ( int i = 0; i < dirs.length; i++ )
             {
@@ -272,7 +273,7 @@
                 throw new TransferFailedException( "Unable to return to the base directory" );
             }
 
-            os = ftp.storeFileStream( resource.getName() );
+            os = ftp.storeFileStream( getTempResourceName( resource ) );
 
             if ( os == null )
             {
@@ -384,4 +385,25 @@
     {
         super.fireSessionDebug( msg );
     }
+
+    /**
+     * Transfer and rename temp file to final in remote server
+     */
+    protected void transfer( Resource resource, File source, OutputStream output, boolean closeOutput )
+        throws TransferFailedException
+    {
+        super.transfer( resource, source, output, closeOutput );
+
+        try
+        {
+            ftp.sendCommand( FTPCommand.RENAME_FROM, getTempResourceName( resource ) );
+
+            ftp.sendCommand( FTPCommand.RENAME_TO, resource.getName() );
+        }
+        catch ( IOException e )
+        {
+            throw new TransferFailedException( "Error renaming temp file in remote FTP server", e );
+        }
+    }
+
 }
Index: wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java
===================================================================
--- wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java	(revision 409022)
+++ wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon.providers.sshext;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -360,8 +360,17 @@
 
         firePutStarted( resource, source );
 
-        executeScpCommand( source, basedir + "/" + resourceName, true );
+        executeScpCommand( source, basedir + "/" + getTempResourceName( resource ), true );
 
+        try
+        {
+            executeCommand( "mv " + getTempResourceName( resource ) + " " + resource.getName() );
+        }
+        catch ( CommandExecutionException e)
+        {
+            throw new TransferFailedException( "Error moving temp file to final destination in remote server", e );
+        }
+
         postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );
 
         try
@@ -386,6 +395,7 @@
             throw new TransferFailedException( "Error executing command for transfer", e );
         }
         firePutCompleted( resource, source );
+
     }
 
     public void executeCommand( String command )
@@ -541,4 +551,5 @@
     {
         return true;
     }
+
 }
Index: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java
===================================================================
--- wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java	(revision 409022)
+++ wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractSshWagon.java	(working copy)
@@ -574,4 +574,35 @@
     {
         return true;
     }
+    
+    protected void renameTempFile( Resource resource )
+        throws TransferFailedException
+    {
+        try
+        {
+            executeCommand( "mv " + getTempResourceName( resource ) + " " + resource.getName() );
+        }
+        catch ( CommandExecutionException e )
+        {
+            throw new TransferFailedException( "Error moving temporary filename to final destination", e );
+        }
+    }
+
+    protected void transfer( Resource resource, File source, OutputStream output, boolean closeOutput )
+        throws TransferFailedException
+    {
+        super.transfer( resource, source, output, closeOutput );
+
+//        try
+//        {
+//            ftp.sendCommand( FTPCommand.RENAME_FROM, getTempResourceName( resource ) );
+//
+//            ftp.sendCommand( FTPCommand.RENAME_TO, resource.getName() );
+//        }
+//        catch ( IOException e )
+//        {
+//            throw new TransferFailedException( "Error renaming temp file in remote FTP server", e );
+//        }
+    }
+
 }
Index: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
===================================================================
--- wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java	(revision 409022)
+++ wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon.providers.ssh;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -147,11 +147,11 @@
 
             if ( resourceName.lastIndexOf( PATH_SEPARATOR ) > 0 )
             {
-                command += resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR ) + 1 );
+                command += getTempResourceName( resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR ) + 1 ) );
             }
             else
             {
-                command += resourceName;
+                command += getTempResourceName( resource );
             }
 
             command += "\n";
@@ -196,6 +196,8 @@
             }
         }
 
+        renameTempFile( resource );
+        
         try
         {
             if ( permissions != null && permissions.getGroup() != null )
Index: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java
===================================================================
--- wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java	(revision 409022)
+++ wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/SftpWagon.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon.providers.ssh;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -72,11 +72,11 @@
 
         if ( resourceName.lastIndexOf( PATH_SEPARATOR ) > 0 )
         {
-            filename = resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR ) + 1 );
+            filename = getTempResourceName( resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR ) + 1 ) );
         }
         else
         {
-            filename = resourceName;
+            filename = getTempResourceName( resource );
         }
 
         try
@@ -99,6 +99,8 @@
 
             channel.put( source.getAbsolutePath(), filename );
 
+            renameTempFile( resource );
+
             postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );
 
             if ( permissions != null && permissions.getGroup() != null )
@@ -345,7 +347,6 @@
         return bDownloaded;
     }
 
-
     public void get( String resourceName, File destination )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
Index: wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/SftpWagonTest.java
===================================================================
--- wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/SftpWagonTest.java	(revision 409022)
+++ wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/SftpWagonTest.java	(working copy)
@@ -1,7 +1,7 @@
 package org.apache.maven.wagon.providers.ssh;
 
 /*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
 import org.apache.maven.wagon.WagonTestCase;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 
-import java.io.File;
-
 /**
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
Index: wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
===================================================================
--- wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java	(revision 409075)
+++ wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java	(working copy)
@@ -190,11 +190,11 @@
 
         if ( dest.endsWith( "/" ) )
         {
-            dest = dest + resource.getName();
+            dest = dest + getTempResourceName( resource );
         }
         else
         {
-            dest = dest + "/" + resource.getName();
+            dest = dest + "/" + getTempResourceName( resource );
         }
 
         firePutInitiated( resource, source );
@@ -294,6 +294,20 @@
 
             throw new TransferFailedException( msg, e );
         }
+
+        try
+        {
+        	wdresource.moveMethod( getTempResourceName( resource ), resource.getName() );
+        }
+        catch( HttpException e )
+        {
+        	throw new TransferFailedException( "Failed to move temporary to final destination", e );
+        }
+        catch( IOException e )
+        {
+            throw new TransferFailedException( "Failed to move temporary to final destination", e );
+        }
+
         firePutCompleted( resource, source );
     }
 

