mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 23:17:03 +08:00
Merge remote-tracking branch
'origin/GP-1141_ghidra1_HiddenMergeFileCleanup' (Closes #1701)
This commit is contained in:
+46
@@ -590,6 +590,27 @@ public class IndexedLocalFileSystem extends LocalFileSystem {
|
|||||||
|
|
||||||
indexJournal.open();
|
indexJournal.open();
|
||||||
try {
|
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);
|
Folder folder = addFolderToIndexIfMissing(parentPath);
|
||||||
Item item = new Item(folder, name, pfile.getStorageName());
|
Item item = new Item(folder, name, pfile.getStorageName());
|
||||||
bumpNextFileIndexID(item.getStorageName());
|
bumpNextFileIndexID(item.getStorageName());
|
||||||
@@ -753,6 +774,26 @@ public class IndexedLocalFileSystem extends LocalFileSystem {
|
|||||||
return folder;
|
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
|
* Find an existing storage location
|
||||||
* @param folderPath
|
* @param folderPath
|
||||||
@@ -1060,6 +1101,11 @@ public class IndexedLocalFileSystem extends LocalFileSystem {
|
|||||||
newFolder = getFolder(newFolderPath, GetFolderOption.CREATE_ALL_NOTIFY);
|
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,
|
folderItem.moveTo(item.itemStorage.dir, item.itemStorage.storageName, newFolderPath,
|
||||||
newName);
|
newName);
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -218,10 +218,9 @@ public abstract class LocalFileSystem implements FileSystem {
|
|||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.deleteContent(null);
|
item.deleteContent(null);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// make sure we get item out of index
|
// make sure we get item out of index
|
||||||
deallocateItemStorage(folderPath, itemName);
|
deallocateItemStorage(folderPath, itemName);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
String parentPath = folderPath + (folderPath.endsWith(SEPARATOR) ? "" : SEPARATOR);
|
String parentPath = folderPath + (folderPath.endsWith(SEPARATOR) ? "" : SEPARATOR);
|
||||||
for (String subfolder : getFolderNames(folderPath)) {
|
for (String subfolder : getFolderNames(folderPath)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user