### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.files.ui Index: src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java,v retrieving revision 1.28 diff -u -r1.28 SystemUniversalTempFileListener.java --- src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java 2 Jul 2008 15:01:50 -0000 1.28 +++ src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java 3 Oct 2008 14:32:04 -0000 @@ -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,11 +303,10 @@ } // 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)); @@ -374,4 +374,40 @@ e.printStackTrace(); } } + + private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor) + { + IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem(); + String path = remoteFile.getAbsolutePath(); + try { + // get the remote file object again so that we have a fresh remote timestamp + remoteFile.markStale(true); + remoteFile = fs.getRemoteFileObject(path, monitor); + + long timestamp = remoteFile.getLastModified(); + boolean timestampChanged = true; + while (timestampChanged){ // wait until the timestamp stops changing + 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(); + + timestampChanged = (timestamp != nextTimestamp); + timestamp = nextTimestamp; + } + } + catch (SystemMessageException e){ + + } + + return remoteFile; + } } \ No newline at end of file