compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); printOutputLine("N " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine("U " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine("F " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine("- " + localPath, REPORT_LEVEL_ALL); printOutputLine("r " + localPath, REPORT_LEVEL_DIFFERENCES); } else { printOutputLine("R " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine( "Downloading batch of " + downloadPackagesList.size() + " objects", REPORT_LEVEL_ACTIONS); printOutputLine("d " + keyPath, REPORT_LEVEL_DIFFERENCES);
/** * Runs the application, performing the action specified on the given service and local directory paths. * * @param servicePath * the path in service (including the bucket name) to which files are backed-up, or from which files are restored. * @param files * a set of one or more of File objects for Uploads, or a single target directory for Downloads. * @param actionCommand * the action to perform, UP(load) or DOWN(load) * @param cryptoPassword * if non-null, an {@link EncryptionUtil} object is created with the provided password to encrypt or decrypt files. * @param aclString * the ACL to apply to the uploaded object * @param providerId * service provider name: "S3" or "GS" * * @throws Exception */ public void run(String servicePath, List<File> files, String actionCommand, String cryptoPassword, String aclString, String providerId) throws Exception { File[] filesArray = files.toArray(new File[files.size()]); this.run(servicePath, filesArray, actionCommand, cryptoPassword, aclString, providerId); }
printOutputLine("UP " + (doAction ? "" : "[No Action] ") + "Local " + uploadPathSummary + " => " + providerId + "[" + servicePath + "]", throw new SynchronizeException("Only one target directory is allowed for downloads"); printOutputLine("DOWN " + (doAction ? "" : "[No Action] ") + providerId + "[" + servicePath + "] => Local " + files[0], REPORT_LEVEL_NONE); printProgressLine("Listing files in local file system"); Map<String, String> objectKeyToFilepathMap = null; if ("UP".equals(actionCommand)) { uploadLocalDirectory(objectKeyToFilepathMap, bucket, objectPath, aclString, md5GenerationProgressWatcher); } else if ("DOWN".equals(actionCommand)) { restoreToLocalDirectory(objectKeyToFilepathMap, objectPath, files[0], bucket, md5GenerationProgressWatcher);
printHelpAndExit(true); } else if (arg.equalsIgnoreCase("-n") || arg.equalsIgnoreCase("--noaction")) { doAction = false; printHelpAndExit(false); printHelpAndExit(false); } else { System.err.println("ERROR: --properties option must be followed by a file path"); printHelpAndExit(false); printHelpAndExit(false); printHelpAndExit(false); System.err.println("ERROR: Report Level setting \"reportlevel\" must have one of the values " + "0 (no reporting), 1 (actions only), 2 (differences only), 3 (DEFAULT - all reporting)"); printHelpAndExit(false); printHelpAndExit(false); printHelpAndExit(false); if (!credentialsFile.canRead()) { System.err.println("ERROR: Cannot read credentials file '" + credentialsFile + "'"); printHelpAndExit(false); printHelpAndExit(false);
private void displayProgressStatus(String prefix, ThreadWatcher watcher) { String progressMessage = prefix + watcher.getCompletedThreads() + "/" + watcher.getThreadCount(); // Show percentage of bytes transferred, if this info is available. if (watcher.isBytesTransferredInfoAvailable()) { String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal()); long percentage = (int) (((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100); String detailsText = formatTransferDetails(watcher); progressMessage += " - " + percentage + "% of " + bytesTotalStr + (detailsText.length() > 0 ? " (" + detailsText + ")" : ""); } else { long percentage = (int) (((double)watcher.getCompletedThreads() / watcher.getThreadCount()) * 100); progressMessage += " - " + percentage + "%"; } printProgressLine(progressMessage); }
printProgressLine("Listing objects in service" + (isBatchMode && mergedDiscrepancyResults.getCountOfItemsCompared() > 0 ? " (Continuing in batches, objects listed previously: " printProgressLine("Comparing service contents with local system"); FileComparerResults discrepancyResults = fileComparer.buildDiscrepancyLists( objectKeyToFilepathMap, objectsMap, md5GenerationProgressWatcher, isForce);
printOutputLine("UP " + (doAction ? "" : "[No Action] ") + "Local " + uploadPathSummary + " => " + providerId + "[" + servicePath + "]", throw new SynchronizeException("Only one target directory is allowed for downloads"); printOutputLine("DOWN " + (doAction ? "" : "[No Action] ") + providerId + "[" + servicePath + "] => Local " + files[0], REPORT_LEVEL_NONE); printProgressLine("Listing files in local file system"); Map<String, String> objectKeyToFilepathMap = null; if ("UP".equals(actionCommand)) { uploadLocalDirectory(objectKeyToFilepathMap, bucket, objectPath, aclString, md5GenerationProgressWatcher); } else if ("DOWN".equals(actionCommand)) { restoreToLocalDirectory(objectKeyToFilepathMap, objectPath, files[0], bucket, md5GenerationProgressWatcher);
printHelpAndExit(true); } else if (arg.equalsIgnoreCase("-n") || arg.equalsIgnoreCase("--noaction")) { doAction = false; printHelpAndExit(false); printHelpAndExit(false); } else { System.err.println("ERROR: --properties option must be followed by a file path"); printHelpAndExit(false); printHelpAndExit(false); printHelpAndExit(false); System.err.println("ERROR: Report Level setting \"reportlevel\" must have one of the values " + "0 (no reporting), 1 (actions only), 2 (differences only), 3 (DEFAULT - all reporting)"); printHelpAndExit(false); printHelpAndExit(false); printHelpAndExit(false); if (!credentialsFile.canRead()) { System.err.println("ERROR: Cannot read credentials file '" + credentialsFile + "'"); printHelpAndExit(false); printHelpAndExit(false);
private void displayProgressStatus(String prefix, ThreadWatcher watcher) { String progressMessage = prefix + watcher.getCompletedThreads() + "/" + watcher.getThreadCount(); // Show percentage of bytes transferred, if this info is available. if (watcher.isBytesTransferredInfoAvailable()) { String bytesTotalStr = byteFormatter.formatByteSize(watcher.getBytesTotal()); long percentage = (int) (((double)watcher.getBytesTransferred() / watcher.getBytesTotal()) * 100); String detailsText = formatTransferDetails(watcher); progressMessage += " - " + percentage + "% of " + bytesTotalStr + (detailsText.length() > 0 ? " (" + detailsText + ")" : ""); } else { long percentage = (int) (((double)watcher.getCompletedThreads() / watcher.getThreadCount()) * 100); progressMessage += " - " + percentage + "%"; } printProgressLine(progressMessage); }
printProgressLine("Listing objects in service" + (isBatchMode && mergedDiscrepancyResults.getCountOfItemsCompared() > 0 ? " (Continuing in batches, objects listed previously: " printProgressLine("Comparing service contents with local system"); FileComparerResults discrepancyResults = fileComparer.buildDiscrepancyLists( objectKeyToFilepathMap, objectsMap, md5GenerationProgressWatcher, isForce);
compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); printOutputLine("N " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine("U " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine("F " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine("- " + localPath, REPORT_LEVEL_ALL); printOutputLine("r " + localPath, REPORT_LEVEL_DIFFERENCES); } else { printOutputLine("R " + localPath, REPORT_LEVEL_ACTIONS); DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload( object, fileTarget, isGzipEnabled, isEncryptionEnabled, cryptoPassword); printOutputLine( "Downloading batch of " + downloadPackagesList.size() + " objects", REPORT_LEVEL_ACTIONS); printOutputLine("d " + keyPath, REPORT_LEVEL_DIFFERENCES);
/** * Runs the application, performing the action specified on the given service and local directory paths. * * @param servicePath * the path in service (including the bucket name) to which files are backed-up, or from which files are restored. * @param files * a set of one or more of File objects for Uploads, or a single target directory for Downloads. * @param actionCommand * the action to perform, UP(load) or DOWN(load) * @param cryptoPassword * if non-null, an {@link EncryptionUtil} object is created with the provided password to encrypt or decrypt files. * @param aclString * the ACL to apply to the uploaded object * @param providerId * service provider name: "S3" or "GS" * * @throws Exception */ public void run(String servicePath, List<File> files, String actionCommand, String cryptoPassword, String aclString, String providerId) throws Exception { File[] filesArray = files.toArray(new File[files.size()]); this.run(servicePath, filesArray, actionCommand, cryptoPassword, aclString, providerId); }
compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); priorLastKey = result.priorLastKey; printOutputLine("N " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); } else if (discrepancyResults.updatedOnClientKeys.contains(relativeKeyPath)) { printOutputLine("U " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); printOutputLine("F " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); } else { printOutputLine("- " + targetKey, REPORT_LEVEL_ALL); printOutputLine("r " + targetKey, REPORT_LEVEL_DIFFERENCES); } else { printOutputLine("R " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); printOutputLine( "Uploading batch of " + objectsToUpload.size() + " files", REPORT_LEVEL_ACTIONS); } catch (FileNotFoundException e) {
compareLocalAndRemoteFiles(mergedDiscrepancyResults, bucket.getName(), rootObjectPath, priorLastKey, objectKeyToFilepathMap, md5GenerationProgressWatcher); priorLastKey = result.priorLastKey; printOutputLine("N " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); } else if (discrepancyResults.updatedOnClientKeys.contains(relativeKeyPath)) { printOutputLine("U " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); printOutputLine("F " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); } else { printOutputLine("- " + targetKey, REPORT_LEVEL_ALL); printOutputLine("r " + targetKey, REPORT_LEVEL_DIFFERENCES); } else { printOutputLine("R " + targetKey, REPORT_LEVEL_ACTIONS); objectsToUpload.add(new LazyPreparedUploadObject( targetKey, file, md5HashOfFile, aclString, encryptionUtil)); printOutputLine( "Uploading batch of " + objectsToUpload.size() + " files", REPORT_LEVEL_ACTIONS); } catch (FileNotFoundException e) {