Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 115642 Details for
Bug 249544
[usability] Save conflict dialog appears when saving files in the editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch to ensure remote file is current cached version before requery
patch.txt (text/plain), 9.22 KB, created by
David McKnight
on 2008-10-20 18:52:30 EDT
(
hide
)
Description:
patch to ensure remote file is current cached version before requery
Filename:
MIME Type:
Creator:
David McKnight
Created:
2008-10-20 18:52:30 EDT
Size:
9.22 KB
patch
obsolete
>### 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.30 >diff -u -r1.30 SystemUniversalTempFileListener.java >--- src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java 17 Oct 2008 15:33:22 -0000 1.30 >+++ src/org/eclipse/rse/files/ui/resources/SystemUniversalTempFileListener.java 20 Oct 2008 22:47:23 -0000 >@@ -191,6 +191,8 @@ > remoteFile, false, new NullProgressMonitor()); > } > >+ boolean openEditorAfterUpload = false; >+ > // get associated editable > SystemEditableRemoteFile editable = getEditedFile(remoteFile); > if (editable != null && storedModifiedStamp == 0) >@@ -209,7 +211,15 @@ > { > editable = new SystemEditableRemoteFile(remoteFile); > } >+ >+ openEditorAfterUpload = true; >+ editable.setLocalResourceProperties(); >+ } > >+ upload(fs, remoteFile, tempFile, properties, storedModifiedStamp, editable, monitor); >+ >+ if (openEditorAfterUpload){ >+ // moving this to after the upload because otherwise it queries the remote file and that messes up the timestamps needed by upload > final SystemEditableRemoteFile fEditable = editable; > Display.getDefault().asyncExec(new Runnable() { > public void run() { >@@ -223,7 +233,7 @@ > if (fEditable.checkOpenInEditor() != ISystemEditableRemoteObject.NOT_OPEN) > { > try { >- fEditable.openEditor(); >+ fEditable.openEditor(); // open e > } > catch (PartInitException e) { > } >@@ -232,10 +242,7 @@ > fEditable.addAsListener(); > } > }); >- editable.setLocalResourceProperties(); > } >- >- upload(fs, remoteFile, tempFile, properties, storedModifiedStamp, editable, monitor); > } > } > catch (SystemMessageException e) { >@@ -255,8 +262,12 @@ > { > 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(); >+ > > boolean remoteFileDeleted = !remoteFile.exists(); > // compare timestamps >@@ -276,7 +287,7 @@ > } > > catch (RemoteFileSecurityException e) >- { >+ { > DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(e.getSystemMessage()); > Display.getDefault().syncExec(msgAction); > } >@@ -292,28 +303,28 @@ > Display.getDefault().syncExec(msgAction); > } > >+ // requery the file so get the new timestamp >+ remoteFile.markStale(true); >+ remoteFile =fs.getRemoteFileObject(remoteFile.getAbsolutePath(), monitor); > > IRemoteFile parent = remoteFile.getParentRemoteFile(); >- >+ >+ >+ long ts = remoteFile.getLastModified(); >+ >+ // set the stored timestamp to be the same as the remote timestamp >+ properties.setRemoteFileTimeStamp(ts); >+ > ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); > // refresh > if (parent != null) > { > registry.fireEvent(new SystemResourceChangeEvent(parent, ISystemResourceChangeEvents.EVENT_REFRESH, null)); > } >- >- // waiting to make sure the file's timestamp is uptodate >- remoteFile = waitForTimestampToBeUpToDate(remoteFile,remoteModifiedStamp, monitor); >- >- >- >+ > registry.fireEvent(new SystemResourceChangeEvent(remoteFile, ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE, remoteFile)); > >- long ts = remoteFile.getLastModified(); > >- // set the stored timestamp to be the same as the remote timestamp >- properties.setRemoteFileTimeStamp(ts); >- > // indicate that the temp file is no longer dirty > properties.setDirty(false); > editable.updateDirtyIndicator(); >@@ -373,53 +384,4 @@ > e.printStackTrace(); > } > } >- >- private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, long originalTimestamp, IProgressMonitor monitor) >- { >- IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem(); >- String path = remoteFile.getAbsolutePath(); >- try { >- long timestamp = originalTimestamp; >- >- boolean fileUpdated = false; >- boolean timestampChanging = true; >- >- int MAX_TIMES_CHECKED = 100; // make sure we don't wait indefinitely >- int timesChecked = 0; >- >- while ((timestampChanging || !fileUpdated) && !monitor.isCanceled()){ // wait until the timestamp stops changing AND timestamp did change at least once >- 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(); >- >- timestampChanging = (timestamp != nextTimestamp); >- >- if (!fileUpdated){ // indicate the file has changed if the timestamp has >- fileUpdated = timestampChanging; >- } >- >- timestamp = nextTimestamp; >- timesChecked++; >- >- if (timesChecked >= MAX_TIMES_CHECKED){ // we're not expecting this, but it's better to timeout than to hang on this >- SystemBasePlugin.logError("timeout waiting for timestamp after upload of "+ path); //$NON-NLS-1$ >- return remoteFile; >- } >- } >- } >- 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.21 >diff -u -r1.21 SystemUploadConflictAction.java >--- src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java 17 Oct 2008 15:33:22 -0000 1.21 >+++ src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java 20 Oct 2008 22:47:23 -0000 >@@ -198,12 +198,15 @@ > { > IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem(); > SystemIFileProperties properties = new SystemIFileProperties(_tempFile); >- long originalTimestamp = _remoteFile.getLastModified(); >+ >+ // making sure we have the same version as is in the cache >+ _remoteFile = fs.getRemoteFileObject(_remoteFile.getAbsolutePath(), monitor); > > fs.upload(_tempFile.getLocation().makeAbsolute().toOSString(), _remoteFile, SystemEncodingUtil.ENCODING_UTF_8, monitor); > > // wait for timestamp to update before re-fetching remote file >- _remoteFile = waitForTimestampToBeUpToDate(_remoteFile, originalTimestamp, monitor); >+ _remoteFile.markStale(true); >+ _remoteFile = fs.getRemoteFileObject(_remoteFile.getAbsolutePath(), monitor); > > long ts = _remoteFile.getLastModified(); > properties.setRemoteFileTimeStamp(ts); >@@ -220,56 +223,8 @@ > } > return Status.OK_STATUS; > } >- >- private IRemoteFile waitForTimestampToBeUpToDate(IRemoteFile remoteFile, long originalTimestamp, IProgressMonitor monitor) >- { >- IRemoteFileSubSystem fs = remoteFile.getParentRemoteFileSubSystem(); >- String path = remoteFile.getAbsolutePath(); >- try { >- long timestamp = originalTimestamp; >- >- boolean fileUpdated = false; >- boolean timestampChanging = true; >- >- int MAX_TIMES_CHECKED = 100; // make sure we don't wait indefinitely >- int timesChecked = 0; >- >- while ((timestampChanging || !fileUpdated) && !monitor.isCanceled()){ // wait until the timestamp stops changing AND timestamp did change at least once >- 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(); >- >- timestampChanging = (timestamp != nextTimestamp); >- >- if (!fileUpdated){ // indicate the file has changed if the timestamp has >- fileUpdated = timestampChanging; >- } >- >- timestamp = nextTimestamp; >- timesChecked++; >- >- if (timesChecked >= MAX_TIMES_CHECKED){ // we're not expecting this, but it's better to timeout than to hang on this >- SystemBasePlugin.logError("timeout waiting for timestamp after upload of "+ path); //$NON-NLS-1$ >- return remoteFile; >- } >- } >- } >- catch (SystemMessageException e){ >- >- } >- >- return remoteFile; >- } > } >+ > > /** > * This is the default dialog used to handle upload conflicts
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 249544
:
114197
|
114226
|
114319
| 115642 |
117337