### 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 20:43:20 -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,12 +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)); long ts = remoteFile.getLastModified(); @@ -374,4 +373,39 @@ e.printStackTrace(); } } + + private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor) + { + IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem(); + String path = remoteFile.getAbsolutePath(); + try { + 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(); + + System.out.println("ts1="+timestamp); + System.out.println("ts2="+nextTimestamp); + + timestampChanged = (timestamp != nextTimestamp); + timestamp = nextTimestamp; + } + } + catch (SystemMessageException e){ + + } + + return remoteFile; + } } \ No newline at end of file Index: src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java,v retrieving revision 1.18 diff -u -r1.18 SystemUploadConflictAction.java --- src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java 2 Jul 2008 15:01:49 -0000 1.18 +++ src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java 3 Oct 2008 20:43:20 -0000 @@ -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 @@ { 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,38 @@ } return Status.OK_STATUS; } + + private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor) + { + IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem(); + String path = remoteFile.getAbsolutePath(); + try { + 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; + } } /** #P org.eclipse.rse.services.dstore Index: src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java,v retrieving revision 1.74 diff -u -r1.74 DStoreFileService.java --- src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java 23 Jul 2008 19:01:56 -0000 1.74 +++ src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java 3 Oct 2008 20:43:22 -0000 @@ -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.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 @@ 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 @@ //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 @@ available = bufInputStream.available(); } + // if (listener.uploadHasFailed()) // { // showUploadFailedMessage(listener, source); @@ -639,26 +655,18 @@ { 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); -// } } } }