diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java index faebda6b5df..4133f66ae5d 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java @@ -34,6 +34,7 @@ * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding * David McKnight (IBM) - [235221] Files truncated on exit of Eclipse * David McKnight (IBM) - [247189] SystemEditableRemoteFile.openEditor() not updating the default editor properly + * David McKnight (IBM) - [249544] Save conflict dialog appears when saving files in the editor *******************************************************************************/ package org.eclipse.rse.files.ui.resources; @@ -700,6 +701,7 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP // reget the remote file so that we have the right timestamps try { + remoteFile.markStale(true); // as per bug 249544, we should mark stale to ensure we get a fresh copy remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor()); } catch (Exception e) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java index 5a178d434f1..35c0eb840be 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java @@ -257,14 +257,65 @@ public class SystemUniversalTempFileListener extends SystemTempFileListener } + /** + * This method attempts to upload a temporary file in the workspace to a corresponding remote file location. It + * checks whether the timestamp of the remote file has changed since the temporary file was last known to + * be in synch with the remote file. If the timestamp has not changed, then it is assumed that the remote + * file has not changed and therefore it is safe to do an upload. If the timestamp has changed, then the remote + * file must have changed independently and there is a conflict and the upload conflict action is invoked. + * + *
+ * Warning It is important to make sure that the remoteFile that gets passed in is up-to-date AND is the + * current cached version. If the remoteFile is not up-to-date then the timestamp of the actual remote file may + * be wrong and lead to the following problems: + * + *
+ * Because of these problems, it is recommended that, before calling upload(), the remoteFile is retrieved from the cache and is
+ * marked stale like the following example:
+ *
+ *
+ * ...
+ * // get the remote file from the cache
+ * IRemoteFile remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
+ *
+ * // mark it stale
+ * remoteFile.markStale(true);
+ *
+ * // re-query the remote file to make sure you have the latest
+ * remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
+ *
+ * // call upload
+ * upload(fs, remoteFile, ...);
+ * ....
+ *
+ *
+ *
+ * @param fs the file subsystem that corresponds with the file to upload
+ * @param remoteFile the remote file location to upload to
+ * @param tempFile the source temp file to upload
+ * @param properties the remote file properties of the file to upload
+ * @param storedModifiedStamp the last timestamp of the remote file for which a temp file was in synch with the remote file
+ * @param editable the wrapper that associates the remote file, temp file and editor together
+ * @param monitor the progress monitor
+ */
public void upload(IRemoteFileSubSystem fs, IRemoteFile remoteFile, IFile tempFile, SystemIFileProperties properties,
long storedModifiedStamp, SystemEditableRemoteFile editable, IProgressMonitor monitor)
{
try
{
- // make sure the remote file is the current cached version
- remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
-
// get the remote modified timestamp
long remoteModifiedStamp = remoteFile.getLastModified();