GP-4341 Force retained checkout if file is in-use during checkin or add-to-version-control. Deprecated upgrade concept during checkin. Revised manner in which file open for update is updated following a version control operation (perform DBHandle update).

This commit is contained in:
ghidra1 2024-03-20 17:43:49 -04:00
parent 74a5b6f0e1
commit 2dff876f0f
46 changed files with 695 additions and 852 deletions

View file

@ -21,14 +21,13 @@ import javax.swing.Icon;
import db.DBConstants;
import db.DBHandle;
import db.buffers.BufferFile;
import db.buffers.ManagedBufferFile;
import db.buffers.*;
import generic.theme.GIcon;
import ghidra.framework.data.DBContentHandler;
import ghidra.framework.data.DomainObjectMergeManager;
import ghidra.framework.data.*;
import ghidra.framework.model.ChangeSet;
import ghidra.framework.model.DomainObject;
import ghidra.framework.store.*;
import ghidra.framework.store.local.LocalDatabaseItem;
import ghidra.util.InvalidNameException;
import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
@ -371,4 +370,21 @@ public class DataTypeArchiveContentHandler extends DBContentHandler<DataTypeArch
return linkHandler;
}
@Override
public boolean canResetDBSourceFile() {
return true;
}
@Override
public void resetDBSourceFile(FolderItem item, DomainObjectAdapterDB domainObj)
throws IOException {
if (!(item instanceof LocalDatabaseItem dbItem) ||
!(domainObj instanceof DataTypeArchiveDB dataTypeArchive)) {
throw new IllegalArgumentException("LocalDatabaseItem and DataTypeArchiveDB required");
}
LocalManagedBufferFile bf = dbItem.openForUpdate(FolderItem.DEFAULT_CHECKOUT_ID);
dataTypeArchive.getDBHandle().setDBVersionedSourceFile(bf);
getDataTypeArchiveChangeSet(dataTypeArchive, bf);
}
}

View file

@ -509,9 +509,6 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
}
}
/**
* @see ghidra.program.model.listing.Program#invalidate()
*/
@Override
public void invalidate() {
clearCache(false);

View file

@ -20,14 +20,13 @@ import java.io.IOException;
import javax.swing.Icon;
import db.*;
import db.buffers.BufferFile;
import db.buffers.ManagedBufferFile;
import db.buffers.*;
import generic.theme.GIcon;
import ghidra.framework.data.DBWithUserDataContentHandler;
import ghidra.framework.data.DomainObjectMergeManager;
import ghidra.framework.data.*;
import ghidra.framework.model.ChangeSet;
import ghidra.framework.model.DomainObject;
import ghidra.framework.store.*;
import ghidra.framework.store.local.LocalDatabaseItem;
import ghidra.util.InvalidNameException;
import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
@ -58,8 +57,7 @@ public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramD
if (!(obj instanceof ProgramDB)) {
throw new IOException("Unsupported domain object: " + obj.getClass().getName());
}
return createFile((ProgramDB) obj, PROGRAM_CONTENT_TYPE, fs, path, name,
monitor);
return createFile((ProgramDB) obj, PROGRAM_CONTENT_TYPE, fs, path, name, monitor);
}
@Override
@ -363,4 +361,21 @@ public class ProgramContentHandler extends DBWithUserDataContentHandler<ProgramD
return linkHandler;
}
@Override
public boolean canResetDBSourceFile() {
return true;
}
@Override
public void resetDBSourceFile(FolderItem item, DomainObjectAdapterDB domainObj)
throws IOException {
if (!(item instanceof LocalDatabaseItem dbItem) ||
!(domainObj instanceof ProgramDB program)) {
throw new IllegalArgumentException("LocalDatabaseItem and ProgramDB required");
}
LocalManagedBufferFile bf = dbItem.openForUpdate(FolderItem.DEFAULT_CHECKOUT_ID);
program.getDBHandle().setDBVersionedSourceFile(bf);
getProgramChangeSet(program, bf);
}
}

View file

@ -1842,12 +1842,6 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
}
}
@Override
public void invalidate() {
clearCache(false);
fireEvent(new DomainObjectChangeRecord(DomainObjectEvent.RESTORED));
}
@Override
public boolean isChangeable() {
return changeable;

View file

@ -356,12 +356,6 @@ public interface Program extends DataTypeManagerDomainObject, ProgramArchitectur
*/
public Address[] parseAddress(String addrStr, boolean caseSensitive);
/**
* Invalidates any caching in a program.
* NOTE: Over-using this method can adversely affect system performance.
*/
public void invalidate();
/**
* Create a new overlay space based upon the given base AddressSpace
* @param overlaySpaceName the name of the new overlay space.

View file

@ -536,11 +536,6 @@ public class StubProgram implements Program {
throw new UnsupportedOperationException();
}
@Override
public void invalidate() {
throw new UnsupportedOperationException();
}
@Override
public Register getRegister(String name) {
throw new UnsupportedOperationException();