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 195080 Details for
Bug 343977
Warn the user about a wrong sequence number in SaveManager#saveMasterTable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch v.0.1
patch343977.txt (text/plain), 3.94 KB, created by
Szymon Ptaszkiewicz
on 2011-05-09 10:55:40 EDT
(
hide
)
Description:
Patch v.0.1
Filename:
MIME Type:
Creator:
Szymon Ptaszkiewicz
Created:
2011-05-09 10:55:40 EDT
Size:
3.94 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.resources >Index: src/org/eclipse/core/internal/resources/SaveManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java,v >retrieving revision 1.113 >diff -u -r1.113 SaveManager.java >--- src/org/eclipse/core/internal/resources/SaveManager.java 27 Apr 2011 12:30:32 -0000 1.113 >+++ src/org/eclipse/core/internal/resources/SaveManager.java 9 May 2011 14:25:14 -0000 >@@ -224,7 +224,7 @@ > IPath location = workspace.getMetaArea().getSafeTableLocationFor(ResourcesPlugin.PI_RESOURCES); > IPath backup = workspace.getMetaArea().getBackupLocationFor(location); > try { >- saveMasterTable(backup); >+ saveMasterTable(ISaveContext.FULL_SAVE, backup); > } catch (CoreException e) { > Policy.log(e.getStatus()); > backup.toFile().delete(); >@@ -233,7 +233,7 @@ > if (location.toFile().exists() && !location.toFile().delete()) > return; > try { >- saveMasterTable(location); >+ saveMasterTable(ISaveContext.FULL_SAVE, location); > } catch (CoreException e) { > Policy.log(e.getStatus()); > location.toFile().delete(); >@@ -1193,7 +1193,7 @@ > if (kind == ISaveContext.FULL_SAVE) > removeClearDeltaMarks(); > //this must be done after committing save contexts to update participant save numbers >- saveMasterTable(); >+ saveMasterTable(kind); > broadcastLifecycle(DONE_SAVING, contexts, warnings, Policy.subMonitorFor(monitor, 1)); > hookEndSave(kind, project, start); > return warnings; >@@ -1215,14 +1215,16 @@ > } > } > >- protected void saveMasterTable() throws CoreException { >- saveMasterTable(workspace.getMetaArea().getSafeTableLocationFor(ResourcesPlugin.PI_RESOURCES)); >+ protected void saveMasterTable(int kind) throws CoreException { >+ saveMasterTable(kind, workspace.getMetaArea().getSafeTableLocationFor(ResourcesPlugin.PI_RESOURCES)); > } > >- protected void saveMasterTable(IPath location) throws CoreException { >+ protected void saveMasterTable(int kind, IPath location) throws CoreException { > long start = System.currentTimeMillis(); > java.io.File target = location.toFile(); > try { >+ if ((kind == ISaveContext.FULL_SAVE) || (kind == ISaveContext.SNAPSHOT)) >+ validateMasterTableBeforeSave(target); > SafeChunkyOutputStream output = new SafeChunkyOutputStream(target); > try { > masterTable.store(output, "master table"); //$NON-NLS-1$ >@@ -1544,6 +1546,28 @@ > masterTable.setProperty(key, Long.toString(System.currentTimeMillis())); > } > >+ private void validateMasterTableBeforeSave(java.io.File target) throws IOException { >+ if (target.exists()) { >+ MasterTable previousMasterTable = new MasterTable(); >+ SafeChunkyInputStream input = new SafeChunkyInputStream(target); >+ try { >+ previousMasterTable.load(input); >+ String stringValue = previousMasterTable.getProperty(ROOT_SEQUENCE_NUMBER_KEY); >+ // if there was a full save, then there must be a non-null entry for root >+ if (stringValue != null) { >+ int valueInFile = new Integer(stringValue).intValue(); >+ int valueInMemory = new Integer(masterTable.getProperty(ROOT_SEQUENCE_NUMBER_KEY)).intValue(); >+ // new master table must provide greater or equal sequence number for root >+ // throw exception if new value is lower than previous one - we cannot allow to desynchronize master table on disk >+ String message = "Cannot set lower sequence number for root (previous: " + valueInFile + ", new: " + valueInMemory + "). Location: " + target.getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ Assert.isLegal(valueInMemory >= valueInFile, message); >+ } >+ } finally { >+ input.close(); >+ } >+ } >+ } >+ > /** > * Visit the given resource (to depth infinite) and write out extra information > * like markers and sync info. To be called during a full save and project save.
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 343977
:
195080
|
226789