Skip to content
Permalink
Browse files
allow moving across filesystems
Use FileUtils instead of renameTo. Also calculate size before moving.


git-svn-id: https://svn.apache.org/repos/asf/archiva/sandbox/trunk@1615835 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
brettporter committed Aug 5, 2014
1 parent 5b33d7a commit a55ae32e9df9563731bfa3c209a2c48dc2233e7d
Showing 1 changed file with 10 additions and 4 deletions.
@@ -27,6 +27,7 @@
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.redback.components.registry.Registry;
import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.commons.io.FileUtils;
import org.codehaus.plexus.util.SelectorUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,6 +38,7 @@
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -232,6 +234,8 @@ public void processFile( String path, boolean executeOnEntireRepo )
}
}

totalSize += artifactFile.length();

File targetFile = new File( repositoryArchive, path );
if ( dryRun )
{
@@ -241,14 +245,16 @@ public void processFile( String path, boolean executeOnEntireRepo )
{
log.info( "archiving file [" + artifactFile.getAbsolutePath() + "] to [" + targetFile + "]" );

if ( !artifactFile.renameTo( targetFile ) )
try
{
FileUtils.moveFileToDirectory( artifactFile, targetFile.getParentFile(), true );
}
catch ( IOException e )
{
log.error(
"Unknown error moving file [" + artifactFile.getAbsolutePath() + "] to [" + targetFile + "]" );
"Error moving file [" + artifactFile.getAbsolutePath() + "] to [" + targetFile + "]: " + e.getLocalizedMessage(), e );
}
}

totalSize += artifactFile.length();
}

private boolean fileNewerThanTarget( File artifactFile )

0 comments on commit a55ae32

Please sign in to comment.