1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-21 07:05:58 +02:00

[299140] Local Readonly file can't be copied/pasted twice

This commit is contained in:
David McKnight 2010-01-15 15:37:53 +00:00
parent f70123a661
commit 5cf97ddad1
2 changed files with 48 additions and 33 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2009 IBM Corporation and others. * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -58,6 +58,7 @@
* David McKnight (IBM) - [276534] Cache Conflict After Synchronization when Browsing Remote System with Case-Differentiated-Only Filenames * David McKnight (IBM) - [276534] Cache Conflict After Synchronization when Browsing Remote System with Case-Differentiated-Only Filenames
* David McKnight (IBM) - [281712] [dstore] Warning message is needed when disk is full * David McKnight (IBM) - [281712] [dstore] Warning message is needed when disk is full
* David McKnight (IBM) - [234258] [dnd] Drag&Drop a folder silently ignores elements without permissions * David McKnight (IBM) - [234258] [dnd] Drag&Drop a folder silently ignores elements without permissions
* David McKnight (IBM) - [299140] Local Readonly file can't be copied/pasted twice
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.files.ui.resources; package org.eclipse.rse.files.ui.resources;
@ -685,52 +686,55 @@ public class UniversalFileTransferUtility {
String storedEncoding = properties.getEncoding(); String storedEncoding = properties.getEncoding();
String currentEncoding = srcFileOrFolder.getEncoding(); String currentEncoding = srcFileOrFolder.getEncoding();
if (storedTime != currentTime && (storedEncoding == null || !storedEncoding.equals(currentEncoding))) if (storedTime != currentTime || (storedEncoding == null || !storedEncoding.equals(currentEncoding)))
{ {
if (tempFile.exists()) if (tempFile.exists())
{ {
// set the appropriate readonly flag // deal with encoding properties
boolean readOnly = !srcFileOrFolder.canWrite(); if (storedEncoding == null || !storedEncoding.equals(currentEncoding)){
setReadOnly(tempFile, readOnly); // set the appropriate readonly flag
boolean readOnly = !srcFileOrFolder.canWrite();
setReadOnly(tempFile, readOnly);
try try
{
if (remoteEncoding != null)
{ {
if (srcFileOrFolder.isBinary()) if (remoteEncoding != null)
{ {
if (!tempFile.isSynchronized(IResource.DEPTH_ZERO)) if (srcFileOrFolder.isBinary())
{ {
tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/); if (!tempFile.isSynchronized(IResource.DEPTH_ZERO))
{
tempFile.refreshLocal(IResource.DEPTH_ZERO, null/*monitor*/);
}
if (!tempFile.getCharset().equals(remoteEncoding))
{
tempFile.setCharset(remoteEncoding, null);
}
} }
if (!tempFile.getCharset().equals(remoteEncoding)) else
{ {
tempFile.setCharset(remoteEncoding, null); // using text mode so the char set needs to be local
if (properties.getLocalEncoding() != null){
String localEncoding = properties.getLocalEncoding();
tempFile.setCharset(localEncoding, null);
}
// otherwise, the default charset is inherited so no need to set
} }
} }
else }
{ catch (Exception e)
// using text mode so the char set needs to be local {
if (properties.getLocalEncoding() != null){ SimpleSystemMessage errorMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
String localEncoding = properties.getLocalEncoding(); ICommonMessageIds.MSG_OPERATION_FAILED,
tempFile.setCharset(localEncoding, null); IStatus.ERROR, "", e); //$NON-NLS-1$
} resultSet.setMessage(errorMessage);
// otherwise, the default charset is inherited so no need to set return null;
}
} }
} }
catch (Exception e)
{
SimpleSystemMessage errorMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
ICommonMessageIds.MSG_OPERATION_FAILED,
IStatus.ERROR, "", e); //$NON-NLS-1$
resultSet.setMessage(errorMessage);
return null;
}
try try
{ {
// set all properties
setIFileProperties(tempFile, srcFileOrFolder, srcFS); setIFileProperties(tempFile, srcFileOrFolder, srcFS);
} }
catch (Exception e) catch (Exception e)

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2009 IBM Corporation and others. * Copyright (c) 2006, 20010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -44,6 +44,7 @@
* David McKnight (IBM) - [280899] RSE can't open files in some directory, which give the RSEG1067 error me * David McKnight (IBM) - [280899] RSE can't open files in some directory, which give the RSEG1067 error me
* Martin Oberhuber (Wind River) - [285942] Throw exception when listing a non-folder * Martin Oberhuber (Wind River) - [285942] Throw exception when listing a non-folder
* Martin Oberhuber (Wind River) - [286129][api] RemoteFileException(String) violates API contract * Martin Oberhuber (Wind River) - [286129][api] RemoteFileException(String) violates API contract
* David McKnight (IBM) - [299140] Local Readonly file can't be copied/pasted twice
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.services.local.files; package org.eclipse.rse.internal.services.local.files;
@ -405,6 +406,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
inputStream = new FileInputStream(file); inputStream = new FileInputStream(file);
bufInputStream = new BufferedInputStream(inputStream); bufInputStream = new BufferedInputStream(inputStream);
boolean wasReadonly = destinationFile.exists() && !destinationFile.canWrite();
if (wasReadonly){ // tempfile is readonly
// since we're replacing the tempfile that represents the real file, the readonly bit should be removed for the transfer
//destinationFile.setWritable(true);
setReadOnly(destinationFile.getParent(), destinationFile.getName(), false, monitor);
}
outputStream = new FileOutputStream(destinationFile); outputStream = new FileOutputStream(destinationFile);
if (isEncodingConversionRequired) if (isEncodingConversionRequired)
@ -455,6 +463,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
isCancelled = monitor.isCanceled(); isCancelled = monitor.isCanceled();
} }
} }
if (wasReadonly){
destinationFile.setReadOnly();
}
} }
catch (Exception e) catch (Exception e)
{ {