// Download New/Updated/Forced/Replaced objects from S3.
if (doAction && downloadPackagesList.size() > 0) {
DownloadPackage[] downloadPackages = (DownloadPackage[])
downloadPackagesList.toArray(new DownloadPackage[downloadPackagesList.size()]);
(new S3ServiceMulti(s3Service, serviceEventAdaptor)).downloadObjects(bucket, downloadPackages);
if (serviceEventAdaptor.wasErrorThrown()) {
Throwable thrown = serviceEventAdaptor.getErrorThrown();
if (thrown instanceof Exception) {
throw (Exception) thrown;
} else {
throw new Exception(thrown);
}
}
}
} while (priorLastKey != null);
// Delete local files that don't correspond with S3 objects.
ArrayList dirsToDelete = new ArrayList();
Iterator clientOnlyIter = mergedDiscrepancyResults.onlyOnClientKeys.iterator();
while (clientOnlyIter.hasNext()) {
String keyPath = (String) clientOnlyIter.next();
File file = (File) filesMap.get(keyPath);
if (isKeepFiles || isNoDelete) {
printOutputLine("d " + keyPath, REPORT_LEVEL_DIFFERENCES);
} else {
printOutputLine("D " + keyPath, REPORT_LEVEL_ACTIONS);
if (doAction) {
if (file.isDirectory()) {
// Delete directories later, as they may still have files
// inside until this loop completes.
dirsToDelete.add(file);
} else {
file.delete();
}
}
}
}
Iterator dirIter = dirsToDelete.iterator();
while (dirIter.hasNext()) {
File dir = (File) dirIter.next();
dir.delete();
}
// Delete objects in S3 that have been moved to the local computer.
List objectsMoved = new ArrayList();
if (isMoveEnabled) {
objectsMoved.addAll(mergedDiscrepancyResults.onlyOnServerKeys);
objectsMoved.addAll(mergedDiscrepancyResults.updatedOnServerKeys);
objectsMoved.addAll(mergedDiscrepancyResults.updatedOnClientKeys);
objectsMoved.addAll(mergedDiscrepancyResults.alreadySynchronisedKeys);
Collections.sort(objectsMoved);
Iterator objectsMovedIter = objectsMoved.iterator();
List objectsToDelete = new ArrayList();
while (objectsMovedIter.hasNext()) {
String keyPath = (String) objectsMovedIter.next();
S3Object s3Object = new S3Object(keyPath);
printOutputLine("M " + keyPath, REPORT_LEVEL_ACTIONS);
if (doAction) {
objectsToDelete.add(s3Object);
}
}
if (objectsToDelete.size() > 0) {
S3Object[] objects = (S3Object[]) objectsToDelete.toArray(new S3Object[objectsToDelete.size()]);
(new S3ServiceMulti(s3Service, serviceEventAdaptor)).deleteObjects(bucket, objects);
if (serviceEventAdaptor.wasErrorThrown()) {
Throwable thrown = serviceEventAdaptor.getErrorThrown();
if (thrown instanceof Exception) {
throw (Exception) thrown;
} else {