mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 05:45:58 +02:00
[249544] Save conflict dialog appears when saving files in the editor
This commit is contained in:
parent
852606e6f8
commit
8deddd5549
1 changed files with 13 additions and 4 deletions
|
@ -198,11 +198,12 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
|
||||||
{
|
{
|
||||||
IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
|
IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
|
||||||
SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
|
SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
|
||||||
|
long originalTimestamp = _remoteFile.getLastModified();
|
||||||
|
|
||||||
fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
|
fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
|
||||||
|
|
||||||
// wait for timestamp to update before re-fetching remote file
|
// wait for timestamp to update before re-fetching remote file
|
||||||
_remoteFile = waitForTimestampToBeUpToDate(_remoteFile, monitor);
|
_remoteFile = waitForTimestampToBeUpToDate(_remoteFile, originalTimestamp, monitor);
|
||||||
|
|
||||||
long ts = _remoteFile.getLastModified();
|
long ts = _remoteFile.getLastModified();
|
||||||
properties.setRemoteFileTimeStamp(ts);
|
properties.setRemoteFileTimeStamp(ts);
|
||||||
|
@ -220,17 +221,19 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor)
|
private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, long originalTimestamp, IProgressMonitor monitor)
|
||||||
{
|
{
|
||||||
IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
|
IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
|
||||||
String path = remoteFile.getAbsolutePath();
|
String path = remoteFile.getAbsolutePath();
|
||||||
long originalTimestamp = remoteFile.getLastModified();
|
|
||||||
try {
|
try {
|
||||||
long timestamp = originalTimestamp;
|
long timestamp = originalTimestamp;
|
||||||
|
|
||||||
boolean fileUpdated = false;
|
boolean fileUpdated = false;
|
||||||
boolean timestampChanging = true;
|
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
|
while (timestampChanging || !fileUpdated){ // wait until the timestamp stops changing AND timestamp did change at least once
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500); // sleep
|
Thread.sleep(500); // sleep
|
||||||
|
@ -252,6 +255,12 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp = nextTimestamp;
|
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){
|
catch (SystemMessageException e){
|
||||||
|
@ -259,7 +268,7 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn
|
||||||
}
|
}
|
||||||
|
|
||||||
return remoteFile;
|
return remoteFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue