Skip to content

Commit

Permalink
Use FileSystemAbstraction instead FileUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed Oct 10, 2016
1 parent 63e8f24 commit 231d37e
Showing 1 changed file with 8 additions and 18 deletions.
Expand Up @@ -24,25 +24,15 @@
import java.io.IOException;

import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.fs.FileUtils;

public class StoreFiles
{
private static final FilenameFilter STORE_FILE_FILTER = new FilenameFilter()
private static final FilenameFilter STORE_FILE_FILTER = ( dir, name ) ->
{
@Override
public boolean accept( File dir, String name )
{
// Skip log files and tx files from temporary database
return !(
name.startsWith( "metrics" ) ||
name.startsWith( "temp-copy" ) ||
name.startsWith( "raft-messages." ) ||
name.startsWith( "debug." ) ||
name.startsWith( "cluster-state" ) ||
name.startsWith( "store_lock" )
);
}
// Skip log files and tx files from temporary database
return !name.startsWith( "metrics" ) && !name.startsWith( "temp-copy" ) &&
!name.startsWith( "raft-messages." ) && !name.startsWith( "debug." ) &&
!name.startsWith( "cluster-state" ) && !name.startsWith( "store_lock" );
};
private FileSystemAbstraction fs;

Expand All @@ -55,16 +45,16 @@ public void delete( File storeDir ) throws IOException
{
for ( File file : fs.listFiles( storeDir, STORE_FILE_FILTER ) )
{
FileUtils.deleteRecursively( file );
fs.deleteRecursively( file );
}

}

public void moveTo( File source, File target ) throws IOException
void moveTo( File source, File target ) throws IOException
{
for ( File candidate : fs.listFiles( source, STORE_FILE_FILTER ) )
{
FileUtils.moveFileToDirectory( candidate, target );
fs.moveToDirectory( candidate, target );
}
}
}

0 comments on commit 231d37e

Please sign in to comment.