1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 14:45:25 +02:00

[249544] Save conflict dialog appears when saving files in the editor

This commit is contained in:
David McKnight 2008-10-17 15:07:30 +00:00
parent 852606e6f8
commit 8deddd5549

View file

@ -198,11 +198,12 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
{
IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
long originalTimestamp = _remoteFile.getLastModified();
fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
// wait for timestamp to update before re-fetching remote file
_remoteFile = waitForTimestampToBeUpToDate(_remoteFile, monitor);
_remoteFile = waitForTimestampToBeUpToDate(_remoteFile, originalTimestamp, monitor);
long ts = _remoteFile.getLastModified();
properties.setRemoteFileTimeStamp(ts);
@ -220,17 +221,19 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
return Status.OK_STATUS;
}
private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor)
private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, long originalTimestamp, IProgressMonitor monitor)
{
IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
String path = remoteFile.getAbsolutePath();
long originalTimestamp = remoteFile.getLastModified();
try {
long timestamp = originalTimestamp;
boolean fileUpdated = false;
boolean timestampChanging = true;
int MAX_TIMES_CHECKED = 100; // make sure we don't wait indefinitely
int timesChecked = 0;
while (timestampChanging || !fileUpdated){ // wait until the timestamp stops changing AND timestamp did change at least once
try {
Thread.sleep(500); // sleep
@ -252,6 +255,12 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
}
timestamp = nextTimestamp;
timesChecked++;
if (timesChecked >= MAX_TIMES_CHECKED){ // we're not expecting this, but it's better to timeout than to hang on this
SystemBasePlugin.logError("timeout waiting for timestamp after upload of "+ path); //$NON-NLS-1$
return remoteFile;
}
}
}
catch (SystemMessageException e){
@ -259,7 +268,7 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
}
return remoteFile;
}
}
}
/**