From c7632069df3bc95f0192e83cb9cb8496cce0a86b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 21 Feb 2017 13:27:00 -0500 Subject: [PATCH] Convert RemoteHelper.remoteFileDownload to use SubMonitor This patch converts RemoteHelper.remoteFileDownload to use SubMonitor instead of the deprecated SubProgressMonitor. The remoteFileDownload operation consists of two sub-operations, to which I assigned the following weigth: - Download the file to the target (95%) - Change the permissions (5%) Ref: http://www.eclipse.org/articles/Article-Progress-Monitors/article.html Change-Id: I8336f8e853e811a4350f1a63ba64934121ace5d8 Signed-off-by: Simon Marchi --- .../eclipse/cdt/launch/remote/RemoteHelper.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java index bc389c24cb2..7b991d07410 100644 --- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java +++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java @@ -17,7 +17,6 @@ package org.eclipse.cdt.launch.remote; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; @@ -33,7 +32,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.osgi.util.NLS; @@ -97,10 +96,13 @@ public class RemoteHelper { IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET, false); - if (skipDownload) + if (skipDownload) { // Nothing to do. Download is skipped. return; - monitor.beginTask(Messages.RemoteRunLaunchDelegate_2, 100); + } + + SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.RemoteRunLaunchDelegate_2, 100); + try { IRemoteConnection conn = getCurrentConnection(config); IRemoteFileService fs = conn.getService(IRemoteFileService.class); @@ -112,12 +114,14 @@ public class RemoteHelper { if (!localFile.fetchInfo().exists()) { return; } - localFile.copy(remoteFile, EFS.OVERWRITE, monitor); + + localFile.copy(remoteFile, EFS.OVERWRITE, subMonitor.split(95)); + // Need to change the permissions to match the original file // permissions because of a bug in upload Process p = remoteShellExec( config, - "", "chmod", "+x " + spaceEscapify(remoteExePath), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "", "chmod", "+x " + spaceEscapify(remoteExePath), subMonitor.split(5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // Wait if necessary for the permission change try {