Ghidra is a software reverse engineering (SRE) framework
GP-1141 corrected issue with hidden merge file cleanup
ghidra13751eeb1f3cf
diff --git a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedLocalFileSystem.java b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedLocalFileSystem.javaindex 23017290fd..056d4a63b8 100644--- a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedLocalFileSystem.java+++ b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedLocalFileSystem.java@@ -590,6 +590,27 @@ public class IndexedLocalFileSystem extends LocalFileSystem {indexJournal.open();try {+ String conflictedItemStorageName = findItemStorageName(parentPath, name);++ String storageName = pfile.getStorageName();++ if (conflictedItemStorageName != null) {+ try {+ if (storageName.compareTo(conflictedItemStorageName) <= 0) {+ conflictedItemStorageName = storageName;+ return true; // skip conflict orphan+ }++ // remove conflict orphan from index and, add newer item below+ deallocateItemStorage(parentPath, name);+ }+ finally {+ Msg.warn(this,+ "Detected orphaned project file " + conflictedItemStorageName + ": " ++ getPath(parentPath, name));+ }+ }+Folder folder = addFolderToIndexIfMissing(parentPath);Item item = new Item(folder, name, pfile.getStorageName());bumpNextFileIndexID(item.getStorageName());@@ -753,6 +774,26 @@ public class IndexedLocalFileSystem extends LocalFileSystem {return folder;}+ /**+ * Find an existing storage location name+ * @param folderPath+ * @param itemName+ * @return storage location name or null if one not defined within index+ */+ private String findItemStorageName(String folderPath, String name) {+ try {+ Folder folder = getFolder(folderPath, GetFolderOption.READ_ONLY);+ Item item = folder.items.get(name);+ if (item != null) {+ return item.itemStorage.storageName;+ }+ }+ catch (NotFoundException e) {+ // ignore+ }+ return null;+ }+/*** Find an existing storage location* @param folderPath@@ -1060,6 +1101,11 @@ public class IndexedLocalFileSystem extends LocalFileSystem {newFolder = getFolder(newFolderPath, GetFolderOption.CREATE_ALL_NOTIFY);}+ LocalFolderItem conflictFolderItem = getItem(newFolderPath, newName);+ if (conflictFolderItem != null) {+ throw new DuplicateFileException("Item already exists: " + newName);+ }+folderItem.moveTo(item.itemStorage.dir, item.itemStorage.storageName, newFolderPath,newName);diff --git a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/LocalFileSystem.java b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/LocalFileSystem.javaindex a0b3725cde..b569e2b940 100644--- a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/LocalFileSystem.java+++ b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/LocalFileSystem.java@@ -218,10 +218,9 @@ public abstract class LocalFileSystem implements FileSystem {if (item != null) {item.deleteContent(null);}- else {- // make sure we get item out of index- deallocateItemStorage(folderPath, itemName);- }++ // make sure we get item out of index+ deallocateItemStorage(folderPath, itemName);}String parentPath = folderPath + (folderPath.endsWith(SEPARATOR) ? "" : SEPARATOR);for (String subfolder : getFolderNames(folderPath)) {