mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 22:55:26 +02:00
[276534] Cache Conflict After Synchronization when Browsing Remote System with Case-Differentiated-Only Filenames
This commit is contained in:
parent
38f498500c
commit
06f9bbfe7d
3 changed files with 123 additions and 18 deletions
|
@ -128,6 +128,7 @@ import org.eclipse.rse.ui.RSEUIPlugin;
|
|||
import org.eclipse.rse.ui.SystemBasePlugin;
|
||||
import org.eclipse.rse.ui.dialogs.SystemRenameSingleDialog;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
|
@ -193,7 +194,7 @@ public class UniversalFileTransferUtility {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean tempFileAvailable(IFile tempFile, IRemoteFile remoteFile)
|
||||
private static boolean tempFileAvailable(IFile tempFile, IRemoteFile remoteFile) throws RemoteFileIOException
|
||||
{
|
||||
// before we make the transfer to the temp file check whether a temp file already exists
|
||||
if (tempFile.exists() && ((Resource)tempFile).getPropertyManager() != null)
|
||||
|
@ -203,9 +204,10 @@ public class UniversalFileTransferUtility {
|
|||
String replicaRemoteFilePath = properties.getRemoteFilePath();
|
||||
String remoteFilePath = remoteFile.getAbsolutePath();
|
||||
|
||||
if (!replicaRemoteFilePath.equals(remoteFilePath)){
|
||||
// this temp file is for a file of different case
|
||||
return false;
|
||||
if (!remoteFilePath.equals(replicaRemoteFilePath)){
|
||||
// this temp file is for a file of different case
|
||||
Exception e = new Exception(FileResources.FILEMSG_CREATE_FILE_FAILED_EXIST);
|
||||
throw new RemoteFileIOException(e);
|
||||
}
|
||||
|
||||
|
||||
|
@ -251,7 +253,54 @@ public class UniversalFileTransferUtility {
|
|||
|
||||
IFile tempFile = (IFile) tempResource;
|
||||
|
||||
boolean available = tempFileAvailable(tempFile, srcFileOrFolder);
|
||||
boolean available = true;
|
||||
try {
|
||||
tempFileAvailable(tempFile, srcFileOrFolder);
|
||||
}
|
||||
catch (RemoteFileIOException e){
|
||||
// this is the case where a temp file exists for a file of a different case
|
||||
// bug 276534
|
||||
SystemIFileProperties properties = new SystemIFileProperties(tempFile);
|
||||
|
||||
Object obj = properties.getRemoteFileObject();
|
||||
if (obj != null && obj instanceof SystemEditableRemoteFile)
|
||||
{
|
||||
SystemEditableRemoteFile editable = (SystemEditableRemoteFile) obj;
|
||||
if (editable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN){
|
||||
// editor open for this file
|
||||
// for now, best we may be able to do is just keep this one and warn
|
||||
String remotePath = editable.getAbsolutePath();
|
||||
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, remotePath);
|
||||
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
|
||||
|
||||
final SystemMessage message = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||
ISystemFileConstants.MSG_DOWNLOAD_ALREADY_OPEN_IN_EDITOR,
|
||||
IStatus.WARNING, msgTxt, msgDetails);
|
||||
|
||||
runInDisplayThread(new Runnable() {
|
||||
public void run() {
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), message);
|
||||
dlg.open();
|
||||
}});
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
// get rid of the current temp file
|
||||
try {
|
||||
tempFile.delete(true, monitor);
|
||||
}
|
||||
catch (CoreException ex){}
|
||||
tempResource = getTempFileFor(srcFileOrFolder);
|
||||
tempFile = (IFile) tempResource;
|
||||
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// file not being edited, so overwrite it
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
if (available){
|
||||
return tempFile;
|
||||
}
|
||||
|
@ -465,11 +514,54 @@ public class UniversalFileTransferUtility {
|
|||
|
||||
IFile tempFile = (IFile) tempResource;
|
||||
|
||||
boolean available = tempFileAvailable(tempFile, srcFileOrFolder);
|
||||
boolean problem = false;
|
||||
boolean available = true;
|
||||
try {
|
||||
available = tempFileAvailable(tempFile, srcFileOrFolder);
|
||||
}
|
||||
catch (RemoteFileIOException e){
|
||||
// this is the case where a temp file exists for a file of a different case
|
||||
// bug 276534
|
||||
SystemIFileProperties properties = new SystemIFileProperties(tempFile);
|
||||
|
||||
Object obj = properties.getRemoteFileObject();
|
||||
if (obj != null && obj instanceof SystemEditableRemoteFile)
|
||||
{
|
||||
SystemEditableRemoteFile editable = (SystemEditableRemoteFile) obj;
|
||||
if (editable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN){
|
||||
// editor open for this file
|
||||
// for now, best we may be able to do is just keep this one and warn
|
||||
String remotePath = srcFileOrFolder.getAbsolutePath();
|
||||
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, remotePath);
|
||||
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
|
||||
SystemMessage message = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||
ISystemFileConstants.MSG_DOWNLOAD_ALREADY_OPEN_IN_EDITOR,
|
||||
IStatus.WARNING, msgTxt, msgDetails);
|
||||
|
||||
resultSet.setMessage(message);
|
||||
problem = true;
|
||||
}
|
||||
else {
|
||||
// get rid of the current temp file
|
||||
try {
|
||||
tempFile.delete(true, monitor);
|
||||
}
|
||||
catch (CoreException ex){}
|
||||
tempResource = getTempFileFor(srcFileOrFolder);
|
||||
tempFile = (IFile) tempResource;
|
||||
}
|
||||
available = false;
|
||||
}
|
||||
else {
|
||||
// file not being edited, so overwrite it
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (available){
|
||||
resultSet.addResource(tempFile);
|
||||
}
|
||||
else {
|
||||
else if (!problem){
|
||||
listener.addIgnoreFile(tempFile);
|
||||
|
||||
remoteFilesForDownload.add(srcFileOrFolder);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* David McKnight (IBM) [143503] [updating] need a synchronize cache operation
|
||||
* David McKnight (IBM) - [276534] Cache Conflict After Synchronization when Browsing Remote System with Case-Differentiated-Only Filenames
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.internal.files.ui.actions;
|
||||
|
||||
|
@ -34,11 +35,15 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
|
|||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.rse.core.model.ISystemResourceSet;
|
||||
import org.eclipse.rse.core.model.SystemRemoteResourceSet;
|
||||
import org.eclipse.rse.internal.files.ui.Activator;
|
||||
import org.eclipse.rse.internal.files.ui.FileResources;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -55,12 +60,14 @@ public class SynchronizeCacheActionDelegate implements IActionDelegate {
|
|||
|
||||
protected IStructuredSelection fSelection;
|
||||
private IStatus errorStatus;
|
||||
private SystemMessage systemMessage;
|
||||
|
||||
public SynchronizeCacheActionDelegate() {
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
errorStatus = null;
|
||||
systemMessage = null;
|
||||
|
||||
IRemoteFile[] files = getRemoteFiles(fSelection);
|
||||
boolean completed = performCacheRemoteFiles(files);
|
||||
|
@ -74,14 +81,21 @@ public class SynchronizeCacheActionDelegate implements IActionDelegate {
|
|||
ErrorDialog.openError(getShell(), FileResources.MESSAGE_ERROR_CACHING_REMOTE_FILES, null, errorStatus);
|
||||
errorStatus = null;
|
||||
}
|
||||
else if (systemMessage != null){
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), systemMessage);
|
||||
dlg.open();
|
||||
systemMessage = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void cacheRemoteFiles(IRemoteFile[] files, IProgressMonitor monitor)
|
||||
private void cacheRemoteFiles(IRemoteFile[] files, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
SystemRemoteResourceSet[] sets = getResourceSetsFor(files);
|
||||
for (int i = 0; i < sets.length; i++){
|
||||
SystemRemoteResourceSet set = sets[i];
|
||||
set.getAdapter().doDrag(set, monitor);
|
||||
ISystemResourceSet resultSet = set.getAdapter().doDrag(set, monitor);
|
||||
|
||||
systemMessage = resultSet.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +134,8 @@ public class SynchronizeCacheActionDelegate implements IActionDelegate {
|
|||
catch (Exception e) {
|
||||
if (e.getCause() instanceof CoreException) {
|
||||
recordError((CoreException)e.getCause());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Activator.getDefault().getLog().log(new Status(IStatus.ERROR,
|
||||
Activator.getDefault().getBundle().getSymbolicName(),
|
||||
-1, e.getMessage(), e));
|
||||
|
@ -162,6 +177,7 @@ public class SynchronizeCacheActionDelegate implements IActionDelegate {
|
|||
void displayError(String message) {
|
||||
MessageDialog.openError(getShell(), FileResources.MESSAGE_ERROR_CACHING_REMOTE_FILES, message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Records the core exception to be displayed to the user once the action is
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
* David McKnight (IBM) - [254769] Don't get latest file when opening a file always
|
||||
* David McKnight (IBM) - [264607] Unable to delete a broken symlink
|
||||
* David McKnight (IBM) - [276103] Files with names in different cases are not handled properly
|
||||
* David McKnight (IBM) - [276534] Cache Conflict After Synchronization when Browsing Remote System with Case-Differentiated-Only Filenames
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.files.ui.view;
|
||||
|
@ -3447,16 +3448,12 @@ public class SystemViewRemoteFileAdapter
|
|||
SystemIFileProperties properties = new SystemIFileProperties(file);
|
||||
|
||||
Object obj = properties.getRemoteFileObject();
|
||||
if (obj != null && obj instanceof ISystemEditableRemoteObject)
|
||||
if (obj != null && obj instanceof SystemEditableRemoteFile)
|
||||
{
|
||||
ISystemEditableRemoteObject rmtObj = (ISystemEditableRemoteObject) obj;
|
||||
IAdaptable rmtFile = rmtObj.getRemoteObject();
|
||||
if (rmtFile instanceof IRemoteFile)
|
||||
{
|
||||
//((IRemoteFile)rmtFile).markStale(true);
|
||||
SystemEditableRemoteFile rmtObj = (SystemEditableRemoteFile) obj;
|
||||
if (rmtObj.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN){ // if this is open
|
||||
return rmtObj;
|
||||
}
|
||||
|
||||
return rmtObj;
|
||||
}
|
||||
}
|
||||
return new SystemEditableRemoteFile(remoteFile);
|
||||
|
|
Loading…
Add table
Reference in a new issue