/** * Copy the source file system structure into the supplied target location. If the source is a file, the destination will be * created as a file; if the source is a directory, the destination will be created as a directory. * * @param sourceFileOrDirectory the file or directory whose contents are to be copied into the target location * @param destinationFileOrDirectory the location where the copy is to be placed; does not need to exist, but if it does its * type must match that of <code>src</code> * @return the number of files (not directories) that were copied * @throws IllegalArgumentException if the <code>src</code> or <code>dest</code> references are null * @throws IOException */ public static int copy( File sourceFileOrDirectory, File destinationFileOrDirectory ) throws IOException { return copy(sourceFileOrDirectory, destinationFileOrDirectory, null); }
/** * Copy the source file system structure into the supplied target location. If the source is a file, the destination will be * created as a file; if the source is a directory, the destination will be created as a directory. * * @param sourceFileOrDirectory the file or directory whose contents are to be copied into the target location * @param destinationFileOrDirectory the location where the copy is to be placed; does not need to exist, but if it does its * type must match that of <code>src</code> * @return the number of files (not directories) that were copied * @throws IllegalArgumentException if the <code>src</code> or <code>dest</code> references are null * @throws IOException */ public static int copy( File sourceFileOrDirectory, File destinationFileOrDirectory ) throws IOException { return copy(sourceFileOrDirectory, destinationFileOrDirectory, null); }
/** * Copy the source file system structure into the supplied target location. If the source is a file, the destination will be * created as a file; if the source is a directory, the destination will be created as a directory. * * @param sourceFileOrDirectory the file or directory whose contents are to be copied into the target location * @param destinationFileOrDirectory the location where the copy is to be placed; does not need to exist, but if it does its * type must match that of <code>src</code> * @return the number of files (not directories) that were copied * @throws IllegalArgumentException if the <code>src</code> or <code>dest</code> references are null * @throws IOException */ public static int copy( File sourceFileOrDirectory, File destinationFileOrDirectory ) throws IOException { return copy(sourceFileOrDirectory, destinationFileOrDirectory, null); }
String src1 = sourceFileOrDirectory.getPath() + File.separator + list[i]; numberOfFilesCopied += copy(new File(src1), new File(dest1), exclusionFilter);
String src1 = sourceFileOrDirectory.getPath() + File.separator + list[i]; numberOfFilesCopied += copy(new File(src1), new File(dest1), exclusionFilter);
String src1 = sourceFileOrDirectory.getPath() + File.separator + list[i]; numberOfFilesCopied += copy(new File(src1), new File(dest1), exclusionFilter);
@Test @FixFor( "MODE-2302" ) public void shouldRun4_0_0_Beta3_UpgradeFunction() throws Exception { FileUtil.delete("target/legacy_fs_binarystore"); String config = "config/repo-config-persistent-legacy-fsbinary.json"; // copy the test-resources legacy structure onto the configured one FileUtil.copy(new File("src/test/resources/legacy_fs_binarystore"), new File("target/legacy_fs_binarystore")); // this is coming from the test resources final BinaryKey binaryKey = new BinaryKey("ef2138973a86a8929eebe7bf52419b7cde73ba0a"); // first run is empty, so no upgrades will be performed but we'll decrement the last upgrade ID to force an upgrade next // restart startRunStop(repository -> { changeLastUpgradeId(repository, Upgrades.ModeShape_4_0_0_Beta3.INSTANCE.getId() - 1); FileSystemBinaryStore binaryStore = (FileSystemBinaryStore)repository.runningState().binaryStore(); assertFalse("No used binaries expected", binaryStore.getAllBinaryKeys().iterator().hasNext()); assertFalse("The binary should not be found", binaryStore.hasBinary(binaryKey)); File mainStorageDirectory = binaryStore.getDirectory(); File[] files = mainStorageDirectory.listFiles(); assertEquals("Just the trash directory was expected", 1, files.length); File trash = files[0]; assertTrue(trash.isDirectory()); }, config); // run the repo a second time, which should run the upgrade startRunStop(repository -> { FileSystemBinaryStore binaryStore = (FileSystemBinaryStore)repository.runningState().binaryStore(); assertFalse("No used binaries expected", binaryStore.getAllBinaryKeys().iterator().hasNext()); assertTrue("The binary should be found", binaryStore.hasBinary(binaryKey)); }, config); }