mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 22:55:26 +02:00
[249544] Save conflict dialog appears when saving files in the editor
This commit is contained in:
parent
e9b7e72098
commit
f1bd3a26d1
3 changed files with 121 additions and 35 deletions
|
@ -23,6 +23,7 @@
|
|||
* Kevin Doyle (IBM) - [204810] Saving file in Eclipse does not update remote file
|
||||
* Kevin Doyle (IBM) - [210389] Display error dialog when setting file not read-only fails when saving
|
||||
* David McKnight (IBM) - [235221] Files truncated on exit of Eclipse
|
||||
* David McKnight (IBM) - [249544] Save conflict dialog appears when saving files in the editor
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
|
@ -302,12 +303,10 @@ public class SystemUniversalTempFileListener extends SystemTempFileListener
|
|||
}
|
||||
|
||||
// waiting to make sure the file's timestamp is uptodate
|
||||
Thread.sleep(1000);
|
||||
remoteFile = waitForTimestampToBeUpToDate(remoteFile, monitor);
|
||||
|
||||
// get the remote file object again so that we have a fresh remote timestamp
|
||||
remoteFile.markStale(true);
|
||||
remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
|
||||
|
||||
|
||||
registry.fireEvent(new SystemResourceChangeEvent(remoteFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, remoteFile));
|
||||
|
||||
long ts = remoteFile.getLastModified();
|
||||
|
@ -374,4 +373,45 @@ public class SystemUniversalTempFileListener extends SystemTempFileListener
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor)
|
||||
{
|
||||
IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
|
||||
String path = remoteFile.getAbsolutePath();
|
||||
long originalTimestamp = remoteFile.getLastModified();
|
||||
try {
|
||||
long timestamp = originalTimestamp;
|
||||
|
||||
boolean fileUpdated = false;
|
||||
boolean timestampChanging = true;
|
||||
|
||||
while (timestampChanging || !fileUpdated){ // wait until the timestamp stops changing AND timestamp did change at least once
|
||||
try {
|
||||
Thread.sleep(500); // sleep
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
}
|
||||
|
||||
// query the remote file again
|
||||
remoteFile.markStale(true);
|
||||
remoteFile = fs.getRemoteFileObject(path, monitor);
|
||||
|
||||
// what's the timestamp now?
|
||||
long nextTimestamp = remoteFile.getLastModified();
|
||||
|
||||
timestampChanging = (timestamp != nextTimestamp);
|
||||
|
||||
if (!fileUpdated){ // indicate the file has changed if the timestamp has
|
||||
fileUpdated = timestampChanging;
|
||||
}
|
||||
|
||||
timestamp = nextTimestamp;
|
||||
}
|
||||
}
|
||||
catch (SystemMessageException e){
|
||||
|
||||
}
|
||||
|
||||
return remoteFile;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@
|
|||
* David McKnight (IBM) - [224377] "open with" menu does not have "other" option
|
||||
* Xuan Chen (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
|
||||
* David McKnight (IBM) - [235221] Files truncated on exit of Eclipse
|
||||
* David McKnight (IBM) - [249544] Save conflict dialog appears when saving files in the editor
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.files.ui.actions;
|
||||
|
@ -197,16 +198,12 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
|
|||
{
|
||||
IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
|
||||
SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
|
||||
|
||||
fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
|
||||
|
||||
// wait for timestamp to update before re-fetching remote file
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
catch (Exception e){
|
||||
|
||||
}
|
||||
_remoteFile.markStale(true);
|
||||
_remoteFile = fs.getRemoteFileObject(_remoteFile.getAbsolutePath(), new NullProgressMonitor());
|
||||
_remoteFile = waitForTimestampToBeUpToDate(_remoteFile, monitor);
|
||||
|
||||
long ts = _remoteFile.getLastModified();
|
||||
properties.setRemoteFileTimeStamp(ts);
|
||||
properties.setDirty(false);
|
||||
|
@ -222,6 +219,47 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
|
|||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor)
|
||||
{
|
||||
IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
|
||||
String path = remoteFile.getAbsolutePath();
|
||||
long originalTimestamp = remoteFile.getLastModified();
|
||||
try {
|
||||
long timestamp = originalTimestamp;
|
||||
|
||||
boolean fileUpdated = false;
|
||||
boolean timestampChanging = true;
|
||||
|
||||
while (timestampChanging || !fileUpdated){ // wait until the timestamp stops changing AND timestamp did change at least once
|
||||
try {
|
||||
Thread.sleep(500); // sleep
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
}
|
||||
|
||||
// query the remote file again
|
||||
remoteFile.markStale(true);
|
||||
remoteFile = fs.getRemoteFileObject(path, monitor);
|
||||
|
||||
// what's the timestamp now?
|
||||
long nextTimestamp = remoteFile.getLastModified();
|
||||
|
||||
timestampChanging = (timestamp != nextTimestamp);
|
||||
|
||||
if (!fileUpdated){ // indicate the file has changed if the timestamp has
|
||||
fileUpdated = timestampChanging;
|
||||
}
|
||||
|
||||
timestamp = nextTimestamp;
|
||||
}
|
||||
}
|
||||
catch (SystemMessageException e){
|
||||
|
||||
}
|
||||
|
||||
return remoteFile;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
* Martin Oberhuber (Wind River) - [235463][ftp][dstore] Incorrect case sensitivity reported on windows-remote
|
||||
* David McKnight (IBM) - [236039][dstore][efs] DStoreInputStream can report EOF too early - clean up how it waits for the local temp file to be created
|
||||
* David McKnight (IBM) - [240710] [dstore] DStoreFileService.getFile() fails with NPE for valid root files
|
||||
* David McKnight (IBM) - [249544] Save conflict dialog appears when saving files in the editor
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.dstore.files;
|
||||
|
@ -74,6 +75,7 @@ import org.eclipse.dstore.core.model.DataElement;
|
|||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.DataStoreAttributes;
|
||||
import org.eclipse.dstore.core.model.DataStoreResources;
|
||||
import org.eclipse.dstore.core.model.DataStoreSchema;
|
||||
import org.eclipse.dstore.core.model.IDataStoreProvider;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||
|
@ -457,11 +459,27 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
boolean transferSuccessful = false;
|
||||
|
||||
long totalBytes = file.length();
|
||||
|
||||
DataElement uploadLog = findUploadLog();
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
|
||||
|
||||
DataStore ds = getDataStore();
|
||||
DataElement result = ds.find(uploadLog, DE.A_NAME, remotePath,1);
|
||||
if (result == null)
|
||||
{
|
||||
result = ds.createObject(uploadLog, "uploadstatus", remotePath);
|
||||
result.setAttribute(DE.A_SOURCE, "running");
|
||||
result.setAttribute(DE.A_VALUE, "");
|
||||
|
||||
DataElement cmd = getDataStore().findCommandDescriptor(DataStoreSchema.C_SET);
|
||||
|
||||
DataElement setstatus = ds.command(cmd, uploadLog, true);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
String byteStreamHandlerId = getByteStreamHandlerId();
|
||||
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
|
||||
|
||||
|
||||
// create an empty file and append data to it later
|
||||
// this handles the case of uploading empty files as well
|
||||
|
@ -473,9 +491,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
//subMonitor = new SubProgressMonitor(monitor, (int)totalBytes);
|
||||
}
|
||||
|
||||
|
||||
// DataElement uploadLog = findUploadLog();
|
||||
findUploadLog();
|
||||
// listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog);
|
||||
// ds.getDomainNotifier().addDomainListener(listener);
|
||||
|
||||
|
@ -583,6 +598,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
|
||||
available = bufInputStream.available();
|
||||
}
|
||||
|
||||
// if (listener.uploadHasFailed())
|
||||
// {
|
||||
// showUploadFailedMessage(listener, source);
|
||||
|
@ -639,26 +655,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
|||
{
|
||||
if (transferSuccessful)
|
||||
{
|
||||
|
||||
|
||||
// try
|
||||
// {
|
||||
// listener.waitForUpdate(null, 2);
|
||||
//
|
||||
// }
|
||||
// catch (InterruptedException e)
|
||||
// {
|
||||
// UniversalSystemPlugin.logError(CLASSNAME + " InterruptedException while waiting for command", e);
|
||||
// }
|
||||
|
||||
String resultStr = result.getSource();
|
||||
while (!resultStr.equals("success"))
|
||||
{
|
||||
// sleep until the upload is complete
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
}
|
||||
resultStr = result.getSource();
|
||||
}
|
||||
}
|
||||
|
||||
//ds.getDomainNotifier().removeDomainListener(listener);
|
||||
|
||||
// if (listener.uploadHasFailed())
|
||||
// {
|
||||
// showUploadFailedMessage(listener, source);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue