diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java index efda4770d30..210bb67cceb 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java @@ -64,6 +64,7 @@ * David McKnight (IBM) - [298440] jar files in a directory can't be pasted to another system properly * David McKnight (IBM) - [308770] [dstore] Remote Search using old server fails with NPE * David McKnight (IBM) - [339548] [dstore] shouldn't attempt file conversion on empty files + * David McKnight (IBM) - [365780] [dstore] codepage conversion should only occur for different encodings *******************************************************************************/ package org.eclipse.rse.internal.services.dstore.files; @@ -842,26 +843,29 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer if (!isBinary && fileLength > 0){ // do standard conversion if this is text! String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding(); - IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this); + if (!localEncoding.equals(encoding)) {// only do conversion if the encodings are different and the length is non-zero - try { - codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this); - } - catch (RuntimeException e){ - Throwable ex = e.getCause(); - StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED); - msgTxtBuffer.append('\n'); - msgTxtBuffer.append('\n'); - msgTxtBuffer.append(remotePath); - msgTxtBuffer.append('\n'); - msgTxtBuffer.append(encoding); - msgTxtBuffer.append(" -> "); - msgTxtBuffer.append(localEncoding); - - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, - IDStoreMessageIds.FILEMSG_IO_ERROR, - IStatus.ERROR, msgTxtBuffer.toString(), ex); - throw new SystemMessageException(msg); + IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this); + + try { + codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this); + } + catch (RuntimeException e){ + Throwable ex = e.getCause(); + StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED); + msgTxtBuffer.append('\n'); + msgTxtBuffer.append('\n'); + msgTxtBuffer.append(remotePath); + msgTxtBuffer.append('\n'); + msgTxtBuffer.append(encoding); + msgTxtBuffer.append(" -> "); + msgTxtBuffer.append(localEncoding); + + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + IDStoreMessageIds.FILEMSG_IO_ERROR, + IStatus.ERROR, msgTxtBuffer.toString(), ex); + throw new SystemMessageException(msg); + } } } } @@ -1092,26 +1096,28 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer // do standard conversion if this is text! if (!isBinaries[j] && fileLength > 0){ // do standard conversion if this is text! or if the file is empty String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding(); - IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[j], this); - - try { - codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this); - } - catch (RuntimeException e){ - Throwable ex = e.getCause(); - StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED); - msgTxtBuffer.append('\n'); - msgTxtBuffer.append('\n'); - msgTxtBuffer.append(remoteFiles[j]); - msgTxtBuffer.append('\n'); - msgTxtBuffer.append(hostEncodings[j]); - msgTxtBuffer.append(" -> "); - msgTxtBuffer.append(localEncoding); - - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, - IDStoreMessageIds.FILEMSG_IO_ERROR, - IStatus.ERROR, msgTxtBuffer.toString(), ex); - throw new SystemMessageException(msg); + if (!localEncoding.equals(hostEncodings[j])){ + IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[j], this); + + try { + codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this); + } + catch (RuntimeException e){ + Throwable ex = e.getCause(); + StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED); + msgTxtBuffer.append('\n'); + msgTxtBuffer.append('\n'); + msgTxtBuffer.append(remoteFiles[j]); + msgTxtBuffer.append('\n'); + msgTxtBuffer.append(hostEncodings[j]); + msgTxtBuffer.append(" -> "); + msgTxtBuffer.append(localEncoding); + + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, + IDStoreMessageIds.FILEMSG_IO_ERROR, + IStatus.ERROR, msgTxtBuffer.toString(), ex); + throw new SystemMessageException(msg); + } } } }