diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-01-17 16:16:04 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-01-17 16:16:04 +0000 |
commit | 7190a46b85269da49437207cda5f6ca1af2e8205 (patch) | |
tree | c1cb17979256fa0c71ce46abe46e68719da5755f /src | |
parent | 2e2ed1f735aaec8e4dc26541a4f193ec15490648 (diff) | |
download | jackcess-7190a46b85269da49437207cda5f6ca1af2e8205.tar.gz jackcess-7190a46b85269da49437207cda5f6ca1af2e8205.zip |
fix some problems with sporadic usage map corruption
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@217 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r-- | src/changes/changes.xml | 3 | ||||
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/UsageMap.java | 18 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d83c133..77d34a6 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -6,6 +6,9 @@ </properties> <body> <release version="1.1.11" date="TBD"> + <action dev="jahlborn" type="fix"> + Fix some problems with sporadic usage map corruption. + </action> <action dev="jahlborn" type="update"> Move from cvs to subversion. </action> diff --git a/src/java/com/healthmarketscience/jackcess/UsageMap.java b/src/java/com/healthmarketscience/jackcess/UsageMap.java index c0bbd8b..d5f0237 100644 --- a/src/java/com/healthmarketscience/jackcess/UsageMap.java +++ b/src/java/com/healthmarketscience/jackcess/UsageMap.java @@ -657,12 +657,14 @@ public class UsageMap int pageIndex = (int)(pageNumber / getMaxPagesPerUsagePage()); int mapPageNum = getTableBuffer().getInt( calculateMapPagePointerOffset(pageIndex)); - if(mapPageNum <= 0) { + ByteBuffer mapPageBuffer = null; + if(mapPageNum > 0) { + mapPageBuffer = _mapPageHolder.setPage(getPageChannel(), mapPageNum); + } else { // Need to create a new usage map page - mapPageNum = createNewUsageMapPage(pageIndex); + mapPageBuffer = createNewUsageMapPage(pageIndex); + mapPageNum = _mapPageHolder.getPageNumber(); } - ByteBuffer mapPageBuffer = _mapPageHolder.setPage(getPageChannel(), - mapPageNum); updateMap(pageNumber, (pageNumber - (getMaxPagesPerUsagePage() * pageIndex)), mapPageBuffer, add); @@ -674,19 +676,17 @@ public class UsageMap * pointer to it. * @param pageIndex Index of the page reference within the map declaration */ - private int createNewUsageMapPage(int pageIndex) throws IOException { + private ByteBuffer createNewUsageMapPage(int pageIndex) throws IOException + { ByteBuffer mapPageBuffer = _mapPageHolder.setNewPage(getPageChannel()); mapPageBuffer.put(PageTypes.USAGE_MAP); mapPageBuffer.put((byte) 0x01); //Unknown mapPageBuffer.putShort((short) 0); //Unknown - for(int i = 0; i < mapPageBuffer.limit(); ++i) { - mapPageBuffer.get(i); - } int mapPageNum = _mapPageHolder.getPageNumber(); getTableBuffer().putInt(calculateMapPagePointerOffset(pageIndex), mapPageNum); writeTable(); - return mapPageNum; + return mapPageBuffer; } private int calculateMapPagePointerOffset(int pageIndex) { |