mirror of https://github.com/apache/archiva.git
do the same as FileUtils.copyFile do
This commit is contained in:
parent
ec1e655c9d
commit
65bcbc9d45
|
@ -37,6 +37,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
//import org.apache.commons.io.IOUtils;
|
//import org.apache.commons.io.IOUtils;
|
||||||
|
@ -90,7 +91,8 @@ public class DefaultFileLockManagerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock.getFile().delete();
|
lock.getFile().delete();
|
||||||
Files.copy( largeJar.toPath(), lock.getFile().toPath() );
|
Files.copy( largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -108,7 +110,8 @@ public class DefaultFileLockManagerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock.getFile().delete();
|
lock.getFile().delete();
|
||||||
Files.copy( largeJar.toPath(), lock.getFile().toPath() );
|
Files.copy( largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -144,7 +147,8 @@ public class DefaultFileLockManagerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock.getFile().delete();
|
lock.getFile().delete();
|
||||||
Files.copy( largeJar.toPath(), lock.getFile().toPath() );
|
Files.copy( largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -162,7 +166,8 @@ public class DefaultFileLockManagerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock.getFile().delete();
|
lock.getFile().delete();
|
||||||
Files.copy( largeJar.toPath(), lock.getFile().toPath() );
|
Files.copy( largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -179,8 +184,7 @@ public class DefaultFileLockManagerTest
|
||||||
Lock lock = fileLockManager.readFileLock( this.file );
|
Lock lock = fileLockManager.readFileLock( this.file );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Files.copy( lock.getFile().toPath(),
|
Files.copy( lock.getFile().toPath(), new FileOutputStream( File.createTempFile( "foo", ".jar" ) ) );
|
||||||
new FileOutputStream( File.createTempFile( "foo", ".jar" ) ) );
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -198,7 +202,8 @@ public class DefaultFileLockManagerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock.getFile().delete();
|
lock.getFile().delete();
|
||||||
Files.copy( largeJar.toPath(), lock.getFile().toPath() );
|
Files.copy( largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -233,7 +238,8 @@ public class DefaultFileLockManagerTest
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock.getFile().delete();
|
lock.getFile().delete();
|
||||||
Files.copy( largeJar.toPath(), lock.getFile().toPath() );
|
Files.copy( largeJar.toPath(), lock.getFile().toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -250,8 +256,7 @@ public class DefaultFileLockManagerTest
|
||||||
Lock lock = fileLockManager.readFileLock( this.file );
|
Lock lock = fileLockManager.readFileLock( this.file );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Files.copy( lock.getFile().toPath(),
|
Files.copy( lock.getFile().toPath(), new FileOutputStream( File.createTempFile( "foo", ".jar" ) ) );
|
||||||
new FileOutputStream( File.createTempFile( "foo", ".jar" ) ) );
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,6 +90,7 @@ import javax.ws.rs.core.Response;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -530,7 +531,8 @@ public class DefaultRepositoriesService
|
||||||
private void copyFile( File sourceFile, File targetPath, String targetFilename, boolean fixChecksums )
|
private void copyFile( File sourceFile, File targetPath, String targetFilename, boolean fixChecksums )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
Files.copy( sourceFile.toPath(), new File( targetPath, targetFilename ).toPath() );
|
Files.copy( sourceFile.toPath(), new File( targetPath, targetFilename ).toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
|
|
||||||
if ( fixChecksums )
|
if ( fixChecksums )
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -577,7 +578,8 @@ public class DefaultFileUploadService
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
Files.copy( sourceFile.toPath(), new File( targetPath, targetFilename ).toPath() );
|
Files.copy( sourceFile.toPath(), new File( targetPath, targetFilename ).toPath(), StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
StandardCopyOption.COPY_ATTRIBUTES );
|
||||||
|
|
||||||
if ( fixChecksums )
|
if ( fixChecksums )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue