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

Collapse All | Expand All

(-)src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java (-23 / +31 lines)
Lines 48-53 Link Here
48
 * Martin Oberhuber (Wind River) - [235463][ftp][dstore] Incorrect case sensitivity reported on windows-remote
48
 * Martin Oberhuber (Wind River) - [235463][ftp][dstore] Incorrect case sensitivity reported on windows-remote
49
 * 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
49
 * 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
50
 * David McKnight   (IBM)        - [240710] [dstore] DStoreFileService.getFile() fails with NPE for valid root files
50
 * David McKnight   (IBM)        - [240710] [dstore] DStoreFileService.getFile() fails with NPE for valid root files
51
 * David McKnight   (IBM)        - [249544] Save conflict dialog appears when saving files in the editor
51
 *******************************************************************************/
52
 *******************************************************************************/
52
53
53
package org.eclipse.rse.internal.services.dstore.files;
54
package org.eclipse.rse.internal.services.dstore.files;
Lines 74-79 Link Here
74
import org.eclipse.dstore.core.model.DataStore;
75
import org.eclipse.dstore.core.model.DataStore;
75
import org.eclipse.dstore.core.model.DataStoreAttributes;
76
import org.eclipse.dstore.core.model.DataStoreAttributes;
76
import org.eclipse.dstore.core.model.DataStoreResources;
77
import org.eclipse.dstore.core.model.DataStoreResources;
78
import org.eclipse.dstore.core.model.DataStoreSchema;
77
import org.eclipse.dstore.core.model.IDataStoreProvider;
79
import org.eclipse.dstore.core.model.IDataStoreProvider;
78
import org.eclipse.osgi.util.NLS;
80
import org.eclipse.osgi.util.NLS;
79
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
81
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
Lines 457-467 Link Here
457
		boolean transferSuccessful = false;
459
		boolean transferSuccessful = false;
458
460
459
		long totalBytes = file.length();
461
		long totalBytes = file.length();
462
		
463
		DataElement uploadLog = findUploadLog();
464
		String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
465
		
466
		DataStore ds = getDataStore();
467
		DataElement result = ds.find(uploadLog, DE.A_NAME, remotePath,1);
468
		if (result == null) 
469
		{
470
			result = ds.createObject(uploadLog, "uploadstatus", remotePath);
471
			result.setAttribute(DE.A_SOURCE, "running");
472
			result.setAttribute(DE.A_VALUE, "");
473
			
474
			DataElement cmd = getDataStore().findCommandDescriptor(DataStoreSchema.C_SET);
475
			
476
			DataElement setstatus = ds.command(cmd, uploadLog, true);
477
		}
460
478
461
		try
479
		try
462
		{
480
		{
463
			String byteStreamHandlerId = getByteStreamHandlerId();
481
			String byteStreamHandlerId = getByteStreamHandlerId();
464
			String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
482
465
483
466
			// create an empty file and append data to it later
484
			// create an empty file and append data to it later
467
			// this handles the case of uploading empty files as well
485
			// this handles the case of uploading empty files as well
Lines 473-481 Link Here
473
				//subMonitor = new SubProgressMonitor(monitor, (int)totalBytes);
491
				//subMonitor = new SubProgressMonitor(monitor, (int)totalBytes);
474
			}
492
			}
475
493
476
477
//			DataElement uploadLog = findUploadLog();
478
			findUploadLog();
479
//			listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog);
494
//			listener = new FileTransferStatusListener(remotePath, shell, monitor, getConnectorService(), ds, uploadLog);
480
	//		ds.getDomainNotifier().addDomainListener(listener);
495
	//		ds.getDomainNotifier().addDomainListener(listener);
481
496
Lines 583-588 Link Here
583
598
584
				available = bufInputStream.available();
599
				available = bufInputStream.available();
585
			}
600
			}
601
			
586
	//		if (listener.uploadHasFailed())
602
	//		if (listener.uploadHasFailed())
587
		//	{
603
		//	{
588
		//		showUploadFailedMessage(listener, source);
604
		//		showUploadFailedMessage(listener, source);
Lines 639-664 Link Here
639
			{
655
			{
640
			    if (transferSuccessful)
656
			    if (transferSuccessful)
641
			    {
657
			    {
642
658
			    	String resultStr = result.getSource();
643
659
			    	while (!resultStr.equals("success"))
644
//					try
660
			    	{
645
//					{
661
			    		// sleep until the upload is complete
646
//						listener.waitForUpdate(null, 2);
662
			    		try {
647
//
663
			    			Thread.sleep(200);
648
//					}
664
			    		}
649
//					catch (InterruptedException e)
665
			    		catch (InterruptedException e){			    			
650
//					{
666
			    		}
651
//						UniversalSystemPlugin.logError(CLASSNAME + " InterruptedException while waiting for command", e);
667
			    		resultStr = result.getSource();
652
//					}
668
			    	}
653
654
			    }
669
			    }
655
656
				//ds.getDomainNotifier().removeDomainListener(listener);
657
658
//				if (listener.uploadHasFailed())
659
//				{
660
//					showUploadFailedMessage(listener, source);
661
//				}
662
			}
670
			}
663
		}
671
		}
664
	}
672
	}
(-)src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java (-4 / +44 lines)
Lines 23-28 Link Here
23
 * Kevin Doyle 		(IBM)		 - [204810] Saving file in Eclipse does not update remote file
23
 * Kevin Doyle 		(IBM)		 - [204810] Saving file in Eclipse does not update remote file
24
 * Kevin Doyle 		(IBM)		 - [210389] Display error dialog when setting file not read-only fails when saving
24
 * Kevin Doyle 		(IBM)		 - [210389] Display error dialog when setting file not read-only fails when saving
25
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
25
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
26
 * David McKnight   (IBM)        - [249544] Save conflict dialog appears when saving files in the editor
26
 ********************************************************************************/
27
 ********************************************************************************/
27
28
28
package org.eclipse.rse.files.ui.resources;
29
package org.eclipse.rse.files.ui.resources;
Lines 302-313 Link Here
302
				}
303
				}
303
304
304
				// waiting to make sure the file's timestamp is uptodate
305
				// waiting to make sure the file's timestamp is uptodate
305
				Thread.sleep(1000);
306
				remoteFile = waitForTimestampToBeUpToDate(remoteFile, monitor);
306
				
307
				
307
				// get the remote file object again so that we have a fresh remote timestamp
308
				remoteFile.markStale(true);
309
				remoteFile = fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor);
310
				
308
				
309
							
311
				registry.fireEvent(new SystemResourceChangeEvent(remoteFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, remoteFile));
310
				registry.fireEvent(new SystemResourceChangeEvent(remoteFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, remoteFile));
312
			
311
			
313
				long ts = remoteFile.getLastModified();
312
				long ts = remoteFile.getLastModified();
Lines 374-377 Link Here
374
			e.printStackTrace();
373
			e.printStackTrace();
375
		}
374
		}
376
	}
375
	}
376
	
377
	private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor)
378
	{
379
		IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
380
		String path = remoteFile.getAbsolutePath();
381
		long originalTimestamp = remoteFile.getLastModified();
382
		try {
383
			long timestamp = originalTimestamp;
384
385
			boolean fileUpdated = false;
386
			boolean timestampChanging = true;
387
			
388
			while (timestampChanging || !fileUpdated){	// wait until the timestamp stops changing AND timestamp did change at least once		
389
				try {
390
					Thread.sleep(500); // sleep 
391
				}
392
				catch (InterruptedException e){				
393
				}
394
			
395
				// query the remote file again
396
				remoteFile.markStale(true);
397
				remoteFile = fs.getRemoteFileObject(path, monitor);
398
399
				// what's the timestamp now?
400
				long nextTimestamp = remoteFile.getLastModified();		
401
402
				timestampChanging = (timestamp != nextTimestamp);
403
404
				if (!fileUpdated){	// indicate the file has changed if the timestamp has			
405
					fileUpdated = timestampChanging;
406
				}
407
				
408
				timestamp = nextTimestamp;
409
			}
410
		}
411
		catch (SystemMessageException e){
412
			
413
		}
414
		
415
		return remoteFile;
416
	}
377
}
417
}
(-)src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java (-8 / +46 lines)
Lines 21-26 Link Here
21
 * David McKnight   (IBM)        - [224377] "open with" menu does not have "other" option
21
 * David McKnight   (IBM)        - [224377] "open with" menu does not have "other" option
22
 * Xuan Chen        (IBM)        - [225506] [api][breaking] RSE UI leaks non-API types
22
 * Xuan Chen        (IBM)        - [225506] [api][breaking] RSE UI leaks non-API types
23
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
23
 * David McKnight   (IBM)        - [235221] Files truncated on exit of Eclipse
24
 * David McKnight   (IBM)        - [249544] Save conflict dialog appears when saving files in the editor
24
 *******************************************************************************/
25
 *******************************************************************************/
25
26
26
package org.eclipse.rse.internal.files.ui.actions;
27
package org.eclipse.rse.internal.files.ui.actions;
Lines 197-212 Link Here
197
            {
198
            {
198
            	IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
199
            	IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
199
            	SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
200
            	SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
201
            	
200
                fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
202
                fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor);
203
201
                // wait for timestamp to update before re-fetching remote file
204
                // wait for timestamp to update before re-fetching remote file
202
                try {
205
                _remoteFile = waitForTimestampToBeUpToDate(_remoteFile, monitor);
203
                	Thread.sleep(1000);
206
204
                }
205
                catch (Exception e){
206
                	
207
                }
208
                _remoteFile.markStale(true);
209
                _remoteFile = fs.getRemoteFileObject(_remoteFile.getAbsolutePath(), new NullProgressMonitor());
210
                long ts = _remoteFile.getLastModified();
207
                long ts = _remoteFile.getLastModified();
211
                properties.setRemoteFileTimeStamp(ts);
208
                properties.setRemoteFileTimeStamp(ts);
212
                properties.setDirty(false);
209
                properties.setDirty(false);
Lines 222-227 Link Here
222
            }
219
            }
223
            return Status.OK_STATUS;
220
            return Status.OK_STATUS;
224
		}
221
		}
222
		
223
		private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, IProgressMonitor monitor)
224
		{
225
			IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem();
226
			String path = remoteFile.getAbsolutePath();
227
			long originalTimestamp = remoteFile.getLastModified();
228
			try {
229
				long timestamp = originalTimestamp;
230
231
				boolean fileUpdated = false;
232
				boolean timestampChanging = true;
233
				
234
				while (timestampChanging || !fileUpdated){	// wait until the timestamp stops changing AND timestamp did change at least once		
235
					try {
236
						Thread.sleep(500); // sleep 
237
					}
238
					catch (InterruptedException e){				
239
					}
240
				
241
					// query the remote file again
242
					remoteFile.markStale(true);
243
					remoteFile = fs.getRemoteFileObject(path, monitor);
244
245
					// what's the timestamp now?
246
					long nextTimestamp = remoteFile.getLastModified();		
247
248
					timestampChanging = (timestamp != nextTimestamp);
249
250
					if (!fileUpdated){	// indicate the file has changed if the timestamp has			
251
						fileUpdated = timestampChanging;
252
					}
253
					
254
					timestamp = nextTimestamp;
255
				}
256
			}
257
			catch (SystemMessageException e){
258
				
259
			}
260
			
261
			return remoteFile;
262
		}		
225
	}
263
	}
226
264
227
	/**
265
	/**

Return to bug 249544