Permalink
Browse files

Uses FileUtils.moveFile for moving to branched directory (since it co…

…uld be on another disk)
  • Loading branch information...
1 parent d5989b4 commit 1613ea5e560c28cd8ae1a9f3dc73c76fdb454abc @tinwelint tinwelint committed Apr 12, 2012
Showing with 9 additions and 16 deletions.
  1. +9 −16 ha/src/main/java/org/neo4j/kernel/HighlyAvailableGraphDatabase.java
@@ -285,20 +285,9 @@ private void migrateBranchedDataDirectoriesToRootDirectory()
}
File targetDir = BranchedDataPolicy.getBranchedDataDirectory( storeDir, timestamp );
- boolean success = false;
try
{
- success = fileSystemAbstraction.renameFile( oldBranchedDir.getAbsolutePath(), targetDir.getAbsolutePath() );
- }
- catch ( IOException e )
- { // OK, let's try copying instead.
- }
- if ( success )
- continue;
-
- try
- {
- fileSystemAbstraction.copyFile( oldBranchedDir.getAbsolutePath(), targetDir.getAbsolutePath() );
+ FileUtils.moveFile( oldBranchedDir, targetDir );
}
catch ( IOException e )
{
@@ -520,8 +509,9 @@ private File getTempDir()
* Moves all files from the temp directory to the current working directory.
* Assumes the target files do not exist and skips over the messages.log
* file the temp db creates.
+ * @throws IOException if move wasn't successful.
*/
- private void moveCopiedStoreIntoWorkingDir()
+ private void moveCopiedStoreIntoWorkingDir() throws IOException
{
File storeDir = new File( getStoreDir() );
for ( File candidate : getTempDir().listFiles( new FileFilter()
@@ -533,7 +523,7 @@ public boolean accept( File file )
}
} ) )
{
- FileUtils.moveFile( candidate, storeDir );
+ FileUtils.moveFileToDirectory( candidate, storeDir );
}
}
@@ -1605,8 +1595,11 @@ protected void moveAwayDb( HighlyAvailableGraphDatabase db, File branchedDataDir
{
for ( File file : relevantDbFiles( db ) )
{
- File dest = new File( branchedDataDir, file.getName() );
- if( !file.renameTo( dest ) )
+ try
+ {
+ FileUtils.moveFileToDirectory( file, branchedDataDir );
+ }
+ catch ( IOException e )
{
db.messageLog.logMessage( "Couldn't move " + file.getPath() );
}

0 comments on commit 1613ea5

Please sign in to comment.