for (int i = 0; i < syncInfos.length; i++) {
if (monitor.isCanceled()) {
return;
}
IResourceVariant remoteVariant = syncInfos[i].getRemote();
IResource resource = syncInfos[i].getLocal();
switch (syncInfos[i].getKind() & SyncInfo.CHANGE_MASK) {
case SyncInfo.ADDITION :
monitor.subTask(NLS.bind(Messages.OverrideWithRemoteOperation_CreatingResource, resource.getName()));
switch (resource.getType()) {
case IResource.FILE :
IStorage storage = remoteVariant.getStorage(null);
// create parent folders of the resource if applicable
createParents(resource);
((IFile) resource).create(storage.getContents(), true, new SubProgressMonitor(monitor, 1));
break;
case IResource.FOLDER :
// technically, the folder shouldn't exist if we're supposed
// to be adding the resource, however, we precreate parents
// of files when creating files and the parent folder may be
// created as a side effect of that, so we add this check
// here, note, not having this call was causing problems in
// RemoteSyncInfo's calculateKind() method
if (!resource.exists()) {
((IFolder) resource).create(true, true, new SubProgressMonitor(monitor, 1));
}
break;
default :
monitor.worked(1);
break;
}
break;
case SyncInfo.CHANGE :
switch (resource.getType()) {
case IResource.FILE :
monitor.subTask(NLS.bind(Messages.OverrideWithRemoteOperation_ReplacingResource, resource.getName()));
IStorage storage = remoteVariant.getStorage(null);
((IFile) resource).setContents(storage.getContents(), true, true, new SubProgressMonitor(monitor, 1));
break;
default :
monitor.worked(1);
break;