From d5083b23c16988bd01f0f14ad407b0028e7a41b4 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Wed, 9 Mar 2011 20:01:33 +0000 Subject: [PATCH] [232084] [local] local file service should not throw operation cancelled exception due to file sizes --- .../services/local/LocalServiceResources.java | 3 +++ .../local/LocalServiceResources.properties | 3 +++ .../services/local/files/LocalFileService.java | 16 +++++++--------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java index 418d2caee56..c9e9d1e06a8 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java @@ -54,6 +54,9 @@ public class LocalServiceResources extends NLS public static String FILEMSG_DELETING; public static String FILEMSG_COPYING; + public static String FILEMSG_ERROR_DOWNLOAD_SIZE; + public static String FILEMSG_ERROR_UPLOAD_SIZE; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, LocalServiceResources.class); diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties index 3dcaeb341cb..0c593572b4c 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties @@ -50,4 +50,7 @@ FILEMSG_COPY_FILE_FAILED_DETAILS=The file system reported the copy operation fai FILEMSG_DELETING =Deleting {0}... FILEMSG_COPYING =Copying {0}... +FILEMSG_ERROR_DOWNLOAD_SIZE=Local download: file size mismatch for {0} +FILEMSG_ERROR_UPLOAD_SIZE=Local upload: file size mismatch for {0} + diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java index 30df42ca97c..99bf27889fc 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java @@ -50,6 +50,7 @@ * David McKnight (IBM) - [331247] Local file paste failed on Vista and Windows 7 * Xuan Chen (IBM) - [222544] [testing] FileServiceArchiveTest leaves temporary files and folders behind in TEMP dir * David McKnight (IBM) - [337612] Failed to copy the content of a tar file + * David McKnight (IBM) - [232084] [local] local file service should not throw operation cancelled exception due to file sizes *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -512,9 +513,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi boolean sizeCheck = !isBinary && systemEncoding.equals(hostEncoding); if (sizeCheck && (destinationFile.length() != file.length())) { - throw new SystemOperationCancelledException(); -// System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$ -// return false; + throw new RemoteFileIOException(new IOException(NLS.bind(LocalServiceResources.FILEMSG_ERROR_DOWNLOAD_SIZE,remoteFile))); } } } @@ -689,7 +688,6 @@ public class LocalFileService extends AbstractFileService implements ILocalServi if (isCancelled) { throw new SystemOperationCancelledException(); -// return false; } else if (destinationFile!=null) { // commented out as per the following bug: // [279829] [local] Save conflict dialog keeps popping up on mounted drive @@ -698,11 +696,11 @@ public class LocalFileService extends AbstractFileService implements ILocalServi //if(!localFile.canWrite()) destinationFile.setReadOnly(); // File lengths can be different if the encodings are different -/* if (destinationFile.length() != localFile.length()) { - // throw new SystemOperationCancelledException(); - System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$ - return false; - }*/ + String systemEncoding = SystemEncodingUtil.getInstance().getEnvironmentEncoding(); + boolean sizeCheck = !isBinary && systemEncoding.equals(hostEncoding); + if (sizeCheck && destinationFile.length() != localFile.length()) { + throw new RemoteFileIOException(new IOException(NLS.bind(LocalServiceResources.FILEMSG_ERROR_UPLOAD_SIZE,remoteFile))); + } } } catch (IOException e)