protected void printTestResult(StorageTestResult testResult) { out.println("Details:"); out.println("- Target connect success: " + testResult.isTargetCanConnect()); out.println("- Target exists: " + testResult.isTargetExists()); out.println("- Target creatable: " + testResult.isTargetCanCreate()); out.println("- Target writable: " + testResult.isTargetCanWrite()); out.println("- Repo file exists: " + testResult.isRepoFileExists()); out.println(); if (testResult.getErrorMessage() != null) { out.println("Error message (see log file for details):"); out.println(" " + testResult.getErrorMessage()); } }
public StorageTestResult test(boolean testCreateTarget) { logger.log(Level.INFO, "Performing storage test TM.test() ..."); StorageTestResult result = new StorageTestResult(); connect(); result.setTargetExists(testTargetExists()); result.setTargetCanWrite(testTargetCanWrite()); result.setRepoFileExists(testRepoFileExists()); if (result.isTargetExists()) { result.setTargetCanCreate(true); result.setTargetCanCreate(testTargetCanCreate()); result.setTargetCanCreate(false); result.setTargetCanConnect(true); result.setTargetCanConnect(false); result.setErrorMessage(StringUtil.getStackTrace(e));
private boolean performRepoTest() { boolean testCreateTarget = options.isCreateTarget(); StorageTestResult testResult = transferManager.test(testCreateTarget); logger.log(Level.INFO, "Storage test result ist " + testResult); if (testResult.isTargetExists() && testResult.isTargetCanWrite() && !testResult.isRepoFileExists()) { logger.log(Level.INFO, "--> OKAY: Target exists and is writable, but repo doesn't exist. We're good to go!"); return true; } else if (testCreateTarget && !testResult.isTargetExists() && testResult.isTargetCanCreate()) { logger.log(Level.INFO, "--> OKAY: Target does not exist, but can be created. We're good to go!"); return true; } else { logger.log(Level.INFO, "--> NOT OKAY: Invalid target/repo state. Operation cannot be continued."); result.setResultCode(InitResultCode.NOK_TEST_FAILED); result.setTestResult(testResult); return false; } }
out.println(); if (testResult.isRepoFileExists()) { out.println("ERROR: Repository cannot be initialized, because it already exists ('syncany' file"); out.println(" exists). Are you sure that you want to create a new repo? Use 'sy connect'"); out.println(" to connect to an existing repository."); else if (!testResult.isTargetCanConnect()) { out.println("ERROR: Repository cannot be initialized, because the connection to the storage backend failed."); out.println(" Possible reasons for this could be connectivity issues (are you connect to the Internet?),"); out.println(" or invalid user credentials (are username/password valid?)."); else if (!testResult.isTargetExists()) { if (!operationOptions.isCreateTarget()) { out.println("ERROR: Repository cannot be initialized, because the target does not exist and"); else if (!testResult.isTargetCanWrite()) { out.println("ERROR: Repository cannot be initialized, because the target is not writable. This is probably"); out.println(" a permission issue (does the user have write permissions to the target?).");
private boolean performRepoTest(TransferManager transferManager) { StorageTestResult testResult = transferManager.test(false); logger.log(Level.INFO, "Storage test result ist " + testResult); if (testResult.isRepoFileExists()) { logger.log(Level.INFO, "--> OKAY: Repo file exists. We're good to go!"); return true; } else { logger.log(Level.INFO, "--> NOT OKAY: Invalid target/repo state. Operation cannot be continued."); result.setResultCode(ConnectResultCode.NOK_TEST_FAILED); result.setTestResult(testResult); return false; } }
out.println(); if (!testResult.isTargetCanConnect()) { out.println("ERROR: Cannot connect to the repository, because the connection to the storage backend failed."); out.println(" Possible reasons for this could be connectivity issues (are you connect to the Internet?),"); out.println(" or invalid user credentials (are username/password valid?)."); else if (!testResult.isTargetExists()) { out.println("ERROR: Cannot connect to the repository, because the target does not exist."); out.println(" Please check if it really exists and if you can read from it / write to it."); else if (!testResult.isTargetCanWrite()) { out.println("ERROR: Cannot connect to the repository, because the target is not writable. This is probably"); out.println(" a permission issue (does the user have write permissions to the target?)."); else if (!testResult.isRepoFileExists()) { out.println("ERROR: Cannot connect to the repository, because no repo file was found ('syncany' file)."); out.println(" Are you sure that this is a valid Syncany repository? Use 'sy init' to create a new one.");