View | Details | Raw Unified | Return to bug 249544 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java (-3 / +54 lines)
Lines 257-270 Link Here
257
257
258
	}
258
	}
259
259
260
	/**
261
	 * This method attempts to upload a temporary file in the workspace to a corresponding remote file location.  It
262
	 * checks whether the timestamp of the remote file has changed since the temporary file was last known to
263
	 * be in synch with the remote file.  If the timestamp has not changed, then it is assumed that the remote
264
	 * file has not changed and therefore it is safe to do an upload.  If the timestamp has changed, then the the remote
265
	 * file must have changed independently and there is a conflict and the upload conflict action is invoked.
266
	 * 
267
	 * <p>
268
	 * <b>Warning</b> It is important to make sure that the remoteFile that gets passed in is up-to-date AND is the 
269
	 * current cached version.  If the remoteFile is not up-to-date then the timestamp of the actual remote file may 
270
	 * be wrong and lead to the following problems:
271
	 * 
272
	 * <ul>
273
	 *   <li> If the detected remote timestamp is not the actual remote timestamp but it is the same as the storedModifiedStamp, an 
274
	 *   upload without detecting a conflict will cause lost data on the remote side!
275
	 *   <li> If the detected remote timestamp is not the actual remote timestamp and the actual timestamp is the same as the 
276
	 *   storedModifiedStamp, a conflict will be indicated that doesn't actually exist
277
	 * </ul>
278
	 * 
279
	 * If the remoteFile is not the current cached version then the following problem occurs.  After the upload, the remote file is
280
	 * marked stale so that the up-to-date remote file can be retrieved with the updated actual timestamp.  Because the remoteFile 
281
	 * that was passed into this method is not the cached version, marking it stale will not mark the cached version stale and 
282
	 * thus, when a re-query of the file is done after the upload, the original cached version gets returned as opposed to a refresh
283
	 * version with the correct timestamp. 
284
	 * 
285
	 * <p>
286
	 * Because of these problems, it is recommended that, before calling upload(), the remoteFile is retrieved from the cached and
287
	 * marked stale and like the following example:
288
	 * 
289
	 * <code>
290
	 *    ...
291
	 *    // get the remote file from the cache
292
	 *    IRemoteFile remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
293
	 *    
294
	 *    // mark it stale
295
	 *    remoteFile.markStale(true);
296
	 *    
297
	 *    // re-query the remote file to make sure you have the latest
298
	 *    remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
299
	 *    
300
	 *    // call upload
301
	 *    upload(fs, remoteFile, ...);
302
	 *    .... 
303
	 * </code>
304
	 * 
305
	 * 
306
	 * @param fs the file subsystem that corresponds with the file to upload
307
	 * @param remoteFile the remote file location to upload to 
308
	 * @param tempFile the source temp file to upload
309
	 * @param properties the remote file properties of the file to upload
310
	 * @param storedModifiedStamp the last timestamp of the remote file for which a temp file was in synch with the remote file
311
	 * @param editable the wrapper that associates the remote file, temp file and editor together
312
	 * @param monitor the progress monitor
313
	 */
260
	public void upload(IRemoteFileSubSystem fs, IRemoteFile remoteFile, IFile tempFile, SystemIFileProperties properties, 
314
	public void upload(IRemoteFileSubSystem fs, IRemoteFile remoteFile, IFile tempFile, SystemIFileProperties properties, 
261
				long storedModifiedStamp, SystemEditableRemoteFile editable, IProgressMonitor monitor)
315
				long storedModifiedStamp, SystemEditableRemoteFile editable, IProgressMonitor monitor)
262
	{
316
	{
263
		try
317
		try
264
		{
318
		{
265
			// make sure the remote file is the current cached version			
266
			remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
267
			
268
			// get the remote modified timestamp
319
			// get the remote modified timestamp
269
			long remoteModifiedStamp = remoteFile.getLastModified();
320
			long remoteModifiedStamp = remoteFile.getLastModified();
270
			
321
			
(-)src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java (+2 lines)
Lines 34-39 Link Here
34
 * David McKnight     (IBM)      - [229610] [api] File transfers should use workspace text file encoding
34
 * David McKnight     (IBM)      - [229610] [api] File transfers should use workspace text file encoding
35
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
35
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
36
 * David McKnight   (IBM)        - [247189] SystemEditableRemoteFile.openEditor() not updating the default editor properly
36
 * David McKnight   (IBM)        - [247189] SystemEditableRemoteFile.openEditor() not updating the default editor properly
37
 * David McKnight   (IBM)        - [249544] Save conflict dialog appears when saving files in the editor
37
 *******************************************************************************/
38
 *******************************************************************************/
38
39
39
package org.eclipse.rse.files.ui.resources;
40
package org.eclipse.rse.files.ui.resources;
Lines 700-705 Link Here
700
		// reget the remote file so that we have the right timestamps
701
		// reget the remote file so that we have the right timestamps
701
		try
702
		try
702
		{
703
		{
704
			remoteFile.markStale(true); // as per bug 249544, we should mark stale to ensure we get a fresh copy
703
			remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor());
705
			remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), new NullProgressMonitor());
704
		}
706
		}
705
		catch (Exception e)
707
		catch (Exception e)

Return to bug 249544