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 226789 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 (rebased to git)
patch343977_201302081730.txt (text/plain), 4.14 KB, created by
Szymon Ptaszkiewicz
on 2013-02-08 11:54:52 EST
(
hide
)
Description:
Patch v.0.1 (rebased to git)
Filename:
MIME Type:
Creator:
Szymon Ptaszkiewicz
Created:
2013-02-08 11:54:52 EST
Size:
4.14 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java >index aa0ed35..751980b 100644 >--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java >+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2012 IBM Corporation and others. >+ * Copyright (c) 2000, 2013 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -225,7 +225,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(); >@@ -234,7 +234,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(); >@@ -1194,7 +1194,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; >@@ -1216,14 +1216,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$ >@@ -1545,6 +1547,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