GP-4692 Corrected post-checkin/merge update of open

database/domain-object
This commit is contained in:
ghidra1 2024-06-12 17:31:22 -04:00
parent 734ff7b669
commit bac18feabf
3 changed files with 85 additions and 20 deletions

View file

@ -78,8 +78,8 @@ public class BufferMgr {
*/
private BufferNode cacheHead;
private BufferNode cacheTail;
private int cacheSize = 0;
private int buffersOnHand = 0;
private int cacheSize;
private int buffersOnHand;
private int lockCount = 0;
/**
@ -235,6 +235,10 @@ public class BufferMgr {
private void initializeCache() throws IOException {
if (lockCount != 0) {
throw new IOException("Unable to re-initialize buffer cache while in-use");
}
if (cacheFile != null) {
cacheFile.delete();
}
@ -244,6 +248,9 @@ public class BufferMgr {
cacheTail = new BufferNode(TAIL, -1);
cacheHead.nextCached = cacheTail;
cacheTail.prevCached = cacheHead;
cacheSize = 0;
buffersOnHand = 0;
// Create disk cache file
cacheFile = new LocalBufferFile(bufferSize, CACHE_FILE_PREFIX, CACHE_FILE_EXT);
@ -257,6 +264,8 @@ public class BufferMgr {
cacheFile.setParameter(name, sourceFile.getParameter(name));
}
}
resetCacheStatistics();
if (alwaysPreCache) {
startPreCacheIfNeeded();
@ -2058,7 +2067,7 @@ public class BufferMgr {
public void resetCacheStatistics() {
cacheHits = 0;
cacheMisses = 0;
lowWaterMark = cacheSize;
lowWaterMark = cacheSize - 1;
}
public String getStatusInfo() {

View file

@ -1149,7 +1149,7 @@ public class GhidraFileData {
if (keepCheckedOut) {
// Maintain exclusive chekout if private repository or file is open for update
// Maintain exclusive checkout if private repository or file is open for update
boolean exclusive = !versionedFileSystem.isShared() || (inUseDomainObj != null);
ProjectLocator projectLocator = parent.getProjectLocator();
@ -1169,6 +1169,11 @@ public class GhidraFileData {
projectLocator.isTransient()));
folderItem.setCheckout(checkout.getCheckoutId(), exclusive,
checkout.getCheckoutVersion(), folderItem.getCurrentVersion());
if (inUseDomainObj != null) {
// Reset source file and change-sets for open database
getContentHandler().resetDBSourceFile(folderItem, inUseDomainObj);
}
}
else {
// NOTE: file open read-only may prevent removal and result in hijack
@ -1180,10 +1185,7 @@ public class GhidraFileData {
// Ignore - should result in Hijacked file
}
}
if (inUseDomainObj != null) {
getContentHandler().resetDBSourceFile(folderItem, inUseDomainObj);
}
} // end of synchronized block
if (inUseDomainObj != null) {
@ -1535,15 +1537,16 @@ public class GhidraFileData {
}
}
}
if (inUseDomainObj != null) {
// Reset source file and change-sets for open database
contentHandler.resetDBSourceFile(folderItem, inUseDomainObj);
}
}
else {
undoCheckout(false, true);
}
if (inUseDomainObj != null) {
contentHandler.resetDBSourceFile(folderItem, inUseDomainObj);
}
} // end of synchronized block
if (inUseDomainObj != null) {
@ -1915,6 +1918,8 @@ public class GhidraFileData {
try {
inUseDomainObj = getAndLockInUseDomainObjectForMergeUpdate("merge");
ContentHandler<?> contentHandler = getContentHandler();
if (!modifiedSinceCheckout()) {
// Quick merge
folderItem.updateCheckout(versionedFolderItem, true, monitor);
@ -1925,8 +1930,6 @@ public class GhidraFileData {
throw new IOException("Merge failed, merge is not supported in headless mode");
}
ContentHandler<?> contentHandler = getContentHandler();
// Test versioned file for VersionException
int mergeVer = versionedFolderItem.getCurrentVersion();
if (!okToUpgrade) {
@ -1995,14 +1998,13 @@ public class GhidraFileData {
versionedFolderItem.updateCheckoutVersion(checkoutId, mergeVer,
ClientUtil.getUserName());
tmpItem = null;
Msg.info(this, "Merge completed for " + name);
if (inUseDomainObj != null) {
contentHandler.resetDBSourceFile(folderItem, inUseDomainObj);
}
}
Msg.info(this, "Updated checkout completed for " + name);
if (inUseDomainObj != null) {
// Reset source file and change-sets for open database
contentHandler.resetDBSourceFile(folderItem, inUseDomainObj);
inUseDomainObj.invalidate();
}
}