@Override public void copyFile( File from, File to ) throws IOException { FileUtils.copyFile( from, to ); }
/** * Utility method that copy a file from its current location to the * provided target directory. * * @param file file that needs to be copied. * @param targetDirectory the destination directory * @throws IOException */ public static void copyFileToDirectory( File file, File targetDirectory ) throws IOException { if ( !targetDirectory.exists() ) { Files.createDirectories( targetDirectory.toPath() ); } if ( !targetDirectory.isDirectory() ) { throw new IllegalArgumentException( "Move target must be a directory, not " + targetDirectory ); } File target = new File( targetDirectory, file.getName() ); copyFile( file, target ); }
public static void copyRecursively( File fromDirectory, File toDirectory, FileFilter filter ) throws IOException { File[] files = fromDirectory.listFiles( filter ); if ( files != null ) { for ( File fromFile : files ) { File toFile = new File( toDirectory, fromFile.getName() ); if ( fromFile.isDirectory() ) { Files.createDirectories( toFile.toPath() ); copyRecursively( fromFile, toFile, filter ); } else { copyFile( fromFile, toFile ); } } } }
copyFile( toMove, target ); deleteFile( toMove );
@Before public void setup() throws Exception { home = testDirectory.directory( "home" ); File baseDir = new File( home, "certificates/default" ); publicCertificateFile = new File( baseDir, "public.crt" ); privateKeyFile = new File( baseDir, "private.key" ); new PkiUtils().createSelfSignedCertificate( publicCertificateFile, privateKeyFile, "localhost" ); File trustedDir = new File( baseDir, "trusted" ); trustedDir.mkdir(); FileUtils.copyFile( publicCertificateFile, new File( trustedDir, "public.crt" ) ); new File( baseDir, "revoked" ).mkdir(); }
@Test public void reportNotCleanLabelIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException { DatabaseLayout databaseLayout = db.databaseLayout(); someData(); db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); File labelIndexFileCopy = databaseLayout.file( "label_index_copy" ); copyFile( databaseLayout.labelScanStore(), labelIndexFileCopy ); db.shutdownAndKeepStore(); copyFile( labelIndexFileCopy, databaseLayout.labelScanStore() ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertTrue( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Label index was not properly shutdown and rebuild is required.") ) ); }
@Test public void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncompleteException { DatabaseLayout databaseLayout = db.databaseLayout(); someData(); db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); File labelIndexFileCopy = databaseLayout.file( "label_index_copy" ); copyFile( databaseLayout.labelScanStore(), labelIndexFileCopy ); try ( Transaction tx = db.beginTx() ) { db.createNode( LABEL_ONE ); tx.success(); } db.shutdownAndKeepStore(); copyFile( labelIndexFileCopy, databaseLayout.labelScanStore() ); ConsistencyCheckService.Result result = fullConsistencyCheck(); assertFalse( "Expected consistency check to fail", result.isSuccessful() ); assertThat( readReport( result ), hasItem( containsString("WARN : Label index was not properly shutdown and rebuild is required.") ) ); }
@Override public void copyFile( File from, File to ) throws IOException { FileUtils.copyFile( from, to ); }
private static void copyIndex(File source, File target) throws IOException { final File indexFile = new File(source, "index.db"); if (indexFile.exists()) { FileUtils.copyFile(indexFile, new File(target, "index.db")); } final File indexDir = new File(source, "index"); if (indexDir.exists()) { FileUtils.copyRecursively(indexDir, new File(target, "index")); } }
private static void copyIndex(File source, File target) throws IOException { final File indexFile = new File(source, "index.db"); if (indexFile.exists()) { FileUtils.copyFile(indexFile, new File(target, "index.db")); } final File indexDir = new File(source, "index"); if (indexDir.exists()) { FileUtils.copyRecursively(indexDir, new File(target, "index")); } }
/** * Utility method that copy a file from its current location to the * provided target directory. * * @param file file that needs to be copied. * @param targetDirectory the destination directory * @throws IOException */ public static void copyFileToDirectory( File file, File targetDirectory ) throws IOException { if ( !targetDirectory.exists() ) { Files.createDirectories( targetDirectory.toPath() ); } if ( !targetDirectory.isDirectory() ) { throw new IllegalArgumentException( "Move target must be a directory, not " + targetDirectory ); } File target = new File( targetDirectory, file.getName() ); copyFile( file, target ); }
public static void copyRecursively( File fromDirectory, File toDirectory, FileFilter filter ) throws IOException { File[] files = fromDirectory.listFiles( filter ); if ( files != null ) { for ( File fromFile : files ) { File toFile = new File( toDirectory, fromFile.getName() ); if ( fromFile.isDirectory() ) { Files.createDirectories( toFile.toPath() ); copyRecursively( fromFile, toFile, filter ); } else { copyFile( fromFile, toFile ); } } } }
copyFile( toMove, target ); deleteFile( toMove );