16972
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/core/FeatureContentProvider.java b/update/org.eclipse.update.core/src/org/eclipse/update/core/FeatureContentProvider.java
index a667187..0fc35d7 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/core/FeatureContentProvider.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/core/FeatureContentProvider.java
@@ -106,6 +106,7 @@
 			InputStream is = null;

 			OutputStream os = null;

 			localFile = Utilities.createLocalFile(getWorkingDirectory(), key, null /*name*/);			

+			boolean sucess = false;

 			try {

 				if (monitor != null) {

 					monitor.saveState();

@@ -118,11 +119,17 @@
 				is = ref.getInputStream();

 				os = new FileOutputStream(localFile);

 				Utilities.copy(is, os, monitor);

-			} catch (IOException e) {

+				sucess = true;

+			} catch (CoreException e) {

 				Utilities.removeLocalFile(key);

-				throw Utilities.newCoreException(Policy.bind("FeatureContentProvider.UnableToCreate",new Object[]{localFile}),e);

+				throw e;

+			} catch (Exception e){

+				Utilities.removeLocalFile(key);

+				throw Utilities.newCoreException(Policy.bind("FeatureContentProvider.UnableToCreate",new Object[]{localFile}),e);				

 			} finally {

-				if (is != null)

+				//Do not close IS if user cancel,

+				//closing IS will read the entire Stream until the end

+				if (sucess && is != null)

 					try {

 						is.close();

 					} catch (IOException e) {

diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/core/JarContentReference.java b/update/org.eclipse.update.core/src/org/eclipse/update/core/JarContentReference.java
index 064bbd2..4fd54d4 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/core/JarContentReference.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/core/JarContentReference.java
@@ -10,6 +10,7 @@
 import java.util.jar.JarEntry;

 import java.util.jar.JarFile;

 

+import org.eclipse.update.core.model.InstallAbortedException;

 import org.eclipse.update.internal.core.*;

 import org.eclipse.update.internal.core.Policy;

 import org.eclipse.update.internal.core.UpdateManagerPlugin;

@@ -131,13 +132,14 @@
 	 * "symbolic" path identifiers for the entries.

 	 * @param monitor progress monitor 

 	 * @exception IOException

+	 * @exception InstallAbortedException

 	 * @since 2.0

 	 */

 	public ContentReference[] unpack(

 		File dir,

 		ContentSelector selector,

 		InstallMonitor monitor)

-		throws IOException {

+		throws IOException, InstallAbortedException {

 

 		// make sure we have a selector

 		if (selector == null)

@@ -208,6 +210,7 @@
 	 * for the entry

 	 * @param monitor progress monitor 

 	 * @exception IOException

+	 * @exception InstallAbortedException

 	 * @since 2.0

 	 */

 	public ContentReference unpack(

@@ -215,7 +218,7 @@
 		String entryName,

 		ContentSelector selector,

 		InstallMonitor monitor)

-		throws IOException {

+		throws IOException, InstallAbortedException {

 

 		// make sure we have a selector

 		if (selector == null)

diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/core/Utilities.java b/update/org.eclipse.update.core/src/org/eclipse/update/core/Utilities.java
index 890555e..e253a18 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/core/Utilities.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/core/Utilities.java
@@ -9,6 +9,8 @@
 import java.util.*;
 
 import org.eclipse.core.runtime.*;
+import org.eclipse.update.core.model.InstallAbortedException;
+import org.eclipse.update.internal.core.Policy;
 import org.eclipse.update.internal.core.UpdateManagerPlugin;
 
 /**
@@ -128,13 +130,14 @@
 	 * @param os output stream
 	 * @param monitor progress monitor
 	 * @exception IOException
+	 * @exception InstallAbortedException
 	 * @since 2.0
 	 */
 	public static void copy(
 		InputStream is,
 		OutputStream os,
 		InstallMonitor monitor)
-		throws IOException {
+		throws IOException, InstallAbortedException {
 		byte[] buf = getBuffer();
 		try {
 			long currentLen = 0;
@@ -142,8 +145,13 @@
 			while (len != -1) {
 				currentLen += len;
 				os.write(buf, 0, len);
-				if (monitor != null)
+				if (monitor != null){
 					monitor.setCopyCount(currentLen);
+					if (monitor.isCanceled()) {
+						String msg = Policy.bind("Feature.InstallationCancelled"); //$NON-NLS-1$
+						throw new InstallAbortedException(msg,null);
+					}
+				}
 				len = is.read(buf);
 			}
 		} finally {
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/UpdateManagerUtils.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/UpdateManagerUtils.java
index 815c734..c6cbf6d 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/UpdateManagerUtils.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/UpdateManagerUtils.java
@@ -12,6 +12,7 @@
 import org.eclipse.core.boot.IPlatformConfiguration;

 import org.eclipse.core.runtime.*;

 import org.eclipse.update.core.*;

+import org.eclipse.update.core.model.InstallAbortedException;

 

 /**

  * 

@@ -157,7 +158,7 @@
 		InputStream sourceContentReferenceStream,

 		String localName,

 		InstallMonitor monitor)

-		throws MalformedURLException, IOException {

+		throws MalformedURLException, IOException, InstallAbortedException {

 		URL result = null;

 		// create the Dir if they do not exist

 		// get the path from the File to resolve File.separator..

diff --git a/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipConverter.java b/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipConverter.java
index 3b0108f..db55e4d 100644
--- a/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipConverter.java
+++ b/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipConverter.java
@@ -21,6 +21,7 @@
 import org.eclipse.update.core.IFeatureContentProvider;
 import org.eclipse.update.core.IPluginEntry;
 import org.eclipse.update.core.JarContentReference;
+import org.eclipse.update.core.model.InstallAbortedException;
 import org.eclipse.update.internal.core.UpdateManagerUtils;

 

 /**

@@ -131,7 +132,7 @@
 		}		
 	}
 	
-	public static void writeSiteManifest(File site, IFeature feature) throws IOException {
+	public static void writeSiteManifest(File site, IFeature feature) throws IOException, InstallAbortedException {
 		File manifest = new File(site, "site.xml");
 		FileOutputStream os = new FileOutputStream(manifest);
 		String siteXML = "<site>\n   <feature url=\"features/"+feature.getVersionedIdentifier().toString()+".jar\"/>\n</site>";
diff --git a/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipFeatureContentProvider.java b/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipFeatureContentProvider.java
index faa301b..98514ed 100644
--- a/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipFeatureContentProvider.java
+++ b/update/org.eclipse.update.examples/src/org/eclipse/update/examples/buildzip/BuildZipFeatureContentProvider.java
@@ -26,6 +26,7 @@
 import org.eclipse.update.core.JarContentReference;

 import org.eclipse.update.core.JarContentReference.ContentSelector;

 import org.eclipse.update.core.model.FeatureModel;

+import org.eclipse.update.core.model.InstallAbortedException;

 import org.eclipse.update.internal.core.UpdateManagerUtils;

 

 /**

@@ -132,7 +133,7 @@
 		return baseReference.peek(manifestName, null/*ContentSelector*/, null/*ProgressMonitor*/);

 	}

 	

-	void unpackFeatureEntryContent(FeatureModel feature, InstallMonitor monitor) throws IOException {

+	void unpackFeatureEntryContent(FeatureModel feature, InstallMonitor monitor) throws IOException, InstallAbortedException {

 			

 		// define selector for feature entry files

 		ContentSelector selector = new ContentSelector() {