Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-5660 Corrected folder rename refresh bug

ghidra1816232981049
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/VersionControl/project_repository.htm b/Ghidra/Features/Base/src/main/help/help/topics/VersionControl/project_repository.htm
index 3108a89912..4718cd2bb4 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/VersionControl/project_repository.htm
+++ b/Ghidra/Features/Base/src/main/help/help/topics/VersionControl/project_repository.htm
@@ -55,10 +55,14 @@
checked out "disappear" from the Ghidra Project Window, as they are unavailable. Private
files remain intact and are not affected by the server connection.</P>
- <P><IMG alt="" src="help/shared/tip.png" border="0">You are authenticated only once per
- Ghidra session; so if you open other project repositories managed by the same Ghidra Server,
- you will be prompted only once for a password, as required.&nbsp;</P>
-
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/tip.png" />
+ You are authenticated only once per
+ Ghidra session; so if you open other project repositories managed by the same Ghidra Server,
+ you will be prompted only once for a password, as required.&nbsp;</P>
+ </BLOCKQUOTE>
+
<H3><A name="Troubleshooting"></A>Troubleshooting a Failed Connection</H3>
<BLOCKQUOTE>
@@ -133,17 +137,25 @@
has not been added to version control (note the plain icon and no version information). It
is considered to be a "private" file. Private files are never visible to other users.</P>
- <P><IMG alt="" src="help/shared/note.png" border="0"> A normal checkout is indicated by a
- checkmark with a green background<IMG alt="" src="images/check.png" border="0">, while an
- exclusive checkout is indicated by checkmark with a blue background<IMG alt="" src=
- "images/checkex.png" border="0">. A checkmark with a red background<IMG alt="" src=
- "images/checkNotLatest.gif" border="0"> indicates that a newer version has been checked-in
- by another user.</P>
-
- <P align="left">A tool tip on the file (let the mouse pointer hover over it) shows the date
- the file was checked out, and the date that is was last modified. An asterisk will appear
- on the file icon to indicate that changes have been made but not checked in.<BR>
- </P>
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/tip.png" />
+ A normal checkout is indicated by a
+ checkmark with a green background<IMG alt="" src="images/check.png" border="0">, while an
+ exclusive checkout is indicated by checkmark with a blue background<IMG alt="" src=
+ "images/checkex.png" border="0">. A checkmark with a red background<IMG alt="" src=
+ "images/checkNotLatest.gif" border="0"> indicates that a newer version has been checked-in
+ by another user.</P>
+ </BLOCKQUOTE>
+
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/note.png" />
+ A tool tip on the file (let the mouse pointer hover over it) shows the date
+ the file was checked out, and the date that is was last modified. An asterisk will appear
+ on the file icon to indicate that changes have been made but not checked in.</P>
+ </BLOCKQUOTE>
+
</BLOCKQUOTE>
<H3>Check Out<A name="CheckOut"></A> <IMG alt="" src="images/vcCheckOut.png" border=
@@ -171,8 +183,12 @@
out. While the exclusive lock exists, no other user can check out the file.<BR>
</P>
- <P><IMG alt="" src="help/shared/note.png" border="0"> The exclusive lock is implied for a
- non-shared project repository.</P>
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/note.png" />
+ The exclusive lock is implied for a non-shared project repository.</P>
+ </BLOCKQUOTE>
+
</BLOCKQUOTE>
<H3>Check In<A name="CheckIn"></A> <IMG alt="" src="images/vcCheckIn.png" border=
@@ -185,11 +201,15 @@
either click on the check in icon <IMG alt="" src="images/vcCheckIn.png" border="0"> on the
tool bar, or right mouse click and select the <B>Check In...</B> option.&nbsp;</P>
- <P><IMG alt="" src="help/shared/tip.png" border="0">The <IMG alt="" src=
- "images/vcCheckIn.png" border="0"> icon is also available from the tool where you have the
- file opened.&nbsp;</P>
+ <P>A dialog is displayed so that you can enter comments that describe your changes.</P>
- <P>A dialog is displayed so that you can enter comments that describe your changes.</P>
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/tip.png" />
+ The <IMG alt="" src="images/vcCheckIn.png" border="0"> toolbar action icon is also
+ available from within the tool where you have the file opened.</P>
+ </BLOCKQUOTE>
+
</BLOCKQUOTE>
<P align="center"><IMG alt="" src="images/CheckInFile.png" border="0"></P>
@@ -240,10 +260,26 @@
<P align="left">If the checkbox on the dialog is selected, then a private file is created
with a ".keep" extension on the filename. The checkbox is selected by default.&nbsp;</P>
- <P align="left"><IMG alt="" src="help/shared/note.png" border="0">If you have the file
- open in the Code Browser when you attempt to undo the check out, you will get an error
- dialog indicating that the file is in use. You must close the file first, then undo check
- out.</P>
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/note.yellow.png" />
+ If you have the file
+ open in the Code Browser when you attempt to undo the check out, you will get an error
+ dialog indicating that the file is in use. You must close the file first, then undo check
+ out.</P>
+ </BLOCKQUOTE>
+
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/note.png" />
+ When a file is checked-out a copy of the file and
+ its folder path is created within the private project data store. When an undo checkout
+ is performed that file and any empty parent folders are removed from the private data
+ store. This is done to ensure any folder name changes or removals within a shared project
+ repository are properly reflected while connected and avoid showing old/stale folders.
+ </P>
+ </BLOCKQUOTE>
+
</BLOCKQUOTE>
<H3>Update<A name="Update"></A> <IMG alt="" src="images/vcMerge.png" border="0">&nbsp;</H3>
@@ -276,12 +312,19 @@
option is only enabled when the latest version number on the server is <B>greater</B> than
the version that you checked out.&nbsp;&nbsp;</P>
- <P><IMG alt="" src="help/shared/tip.png" border="0">&nbsp; The <IMG alt="" src=
- "images/vcMerge.png" border="0"> icon is also available from the tool where you have the
- file opened.</P>
-
- <P><IMG alt="" src="help/shared/note.png" border="0"> The update action is not applicable
- in a non-shared project repository.</P>
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/tip.png" />
+ The <IMG alt="" src="images/vcMerge.png" border="0"> icon is also available from the
+ tool where you have the file opened.</P>
+ </BLOCKQUOTE>
+
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/note.png" />
+ The update action is not applicable in a non-shared project repository.</P>
+ </BLOCKQUOTE>
+
</BLOCKQUOTE>
<H3>&nbsp;</H3>
@@ -343,23 +386,27 @@
version 10 of SharedProgram.exe.&nbsp; You can make changes to the file, but you must save
it to a new name.</P>
- <P><IMG alt="" src="help/shared/tip.png" border="0">&nbsp; Other ways to open a specific
- version in a tool are:</P>
-
- <UL>
- <LI>Drag a version from the <I>Version History</I> dialog to a running tool, the running
- tool's icon, or to a tool icon in the tool chest.</LI>
-
- <LI>If you have a <A href=
- "help/topics/Tool/Ghidra_Tool_Administration.htm#Set_Tool_Associations">default tool</A>
- specified, double click on the version that you want to open.</LI>
-
- <LI>Choose the <B>File</B><IMG alt="" src="help/shared/arrow.gif" border=
- "0"><B>Open...</B> option; the <A href=
- "help/topics/ProgramManagerPlugin/Opening_Program_Files.htm#VersionHistory">Open Program
- dialog</A> is displayed; from this dialog you can select a version to
- open.&nbsp;&nbsp;</LI>
- </UL>
+ <BLOCKQUOTE>
+ <P>
+ <IMG SRC="help/shared/tip.png" />
+ Other ways to open a specific version in a tool are:</P>
+
+ <UL>
+ <LI>Drag a version from the <I>Version History</I> dialog to a running tool, the running
+ tool's icon, or to a tool icon in the tool chest.</LI>
+
+ <LI>If you have a <A href=
+ "help/topics/Tool/Ghidra_Tool_Administration.htm#Set_Tool_Associations">default tool</A>
+ specified, double click on the version that you want to open.</LI>
+
+ <LI>Choose the <B>File</B><IMG alt="" src="help/shared/arrow.gif" border=
+ "0"><B>Open...</B> option; the <A href=
+ "help/topics/ProgramManagerPlugin/Opening_Program_Files.htm#VersionHistory">Open Program
+ dialog</A> is displayed; from this dialog you can select a version to
+ open.&nbsp;&nbsp;</LI>
+ </UL>
+ </BLOCKQUOTE>
+
</BLOCKQUOTE>
<H3>Delete</H3>
diff --git a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/FileSystem.java b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/FileSystem.java
index b0b0ab9d16..6c67fc96c2 100644
--- a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/FileSystem.java
+++ b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/FileSystem.java
@@ -19,6 +19,7 @@ import java.io.*;
import db.buffers.BufferFile;
import db.buffers.ManagedBufferFile;
+import ghidra.framework.store.local.UnknownFolderItem;
import ghidra.util.InvalidNameException;
import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
@@ -77,7 +78,9 @@ public interface FileSystem {
/**
* Returns a list of the folder items contained in the given folder.
* @param folderPath the path of the folder.
- * @return a list of folder items.
+ * @return a list of folder items. Null items may exist if index contained item name
+ * while storage was not found. An {@link UnknownFolderItem} may be returned if unsupported
+ * item storage encountered.
* @throws IOException
*/
public FolderItem[] getItems(String folderPath) throws IOException;
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.java
index d8b2886510..40a28987ea 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
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -167,6 +167,23 @@ public class IndexedLocalFileSystem extends LocalFileSystem {
indexJournal = new IndexJournal();
}
+ @Override
+ public LocalFolderItem[] getItems(String folderPath) throws IOException {
+ String[] itemNames = getItemNames(folderPath, false);
+ LocalFolderItem[] folderItems = new LocalFolderItem[itemNames.length];
+ for (int i = 0; i < itemNames.length; i++) {
+ LocalFolderItem item = getItem(folderPath, itemNames[i]);
+ if (item == null && !readOnly) {
+ // remove item from index where item storage is missing
+ Msg.warn(this, "Removing missing folder item from filesystem index: " +
+ LocalFileSystem.getPath(folderPath, itemNames[i]));
+ itemDeleted(folderPath, itemNames[i]);
+ }
+ folderItems[i] = item;
+ }
+ return folderItems;
+ }
+
@Override
public synchronized void dispose() {
if (rootFolder == null) {
@@ -1286,9 +1303,9 @@ public class IndexedLocalFileSystem extends LocalFileSystem {
/**
* Construct a previously allocated item and add it to the parent's
* item map. The FileID will be read from the Property file.
- * @param parent
- * @param name
- * @param storageName
+ * @param parent parent folder
+ * @param name item name
+ * @param storageName storage name
*/
Item(Folder parent, String name, String storageName) {
this.storageName = storageName;
@@ -1298,9 +1315,9 @@ public class IndexedLocalFileSystem extends LocalFileSystem {
/**
* Set this items parent, name and storage name and add the modified item
* to the specified parent's item map
- * @param parent
- * @param name
- * @param fileId unique file ID from property file content
+ * @param newParent new parent folder
+ * @param newName new item name
+ * @param newFileId unique file ID from property file content
*/
void set(Folder newParent, String newName, String newFileId) {
if (parent != null && itemStorage != null) {
diff --git a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedV1LocalFileSystem.java b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedV1LocalFileSystem.java
index c510deaf77..1647da5dbc 100644
--- a/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedV1LocalFileSystem.java
+++ b/Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/local/IndexedV1LocalFileSystem.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,16 +18,15 @@ package ghidra.framework.store.local;
import java.io.*;
import java.util.HashMap;
-import ghidra.framework.store.FolderItem;
import ghidra.util.Msg;
import ghidra.util.PropertyFile;
import ghidra.util.exception.NotFoundException;
/**
- * <code>IndexedLocalFileSystem</code> implements a case-sensitive indexed filesystem
+ * <code>IndexedV1LocalFileSystem</code> implements a case-sensitive indexed filesystem
* which uses a shallow storage hierarchy with no restriction on file name or path
* length. This filesystem is identified by the existence of an index file (~index.dat)
- * and recovery journal (~index.jrn).
+ * and recovery journal (~index.jrn). File system also maintains a file-ID mapping.
*/
public class IndexedV1LocalFileSystem extends IndexedLocalFileSystem {
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/data/GhidraFolderData.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/data/GhidraFolderData.java
index 42bf0ea340..6a5c786ea4 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/data/GhidraFolderData.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/data/GhidraFolderData.java
@@ -267,6 +267,10 @@ class GhidraFolderData {
if (parent.visited) {
parent.folderList.remove(oldName);
parent.folderList.add(newName);
+
+ // Must force refresh to ensure that all folder items are properly updted with new parent path
+ refresh(true, true, projectData.getProjectDisposalMonitor());
+
listener.domainFolderRenamed(newFolder, oldName);
}
@@ -632,9 +636,8 @@ class GhidraFolderData {
++badItemCount;
continue;
}
- Msg.error(this,
- "Unsupported folder item encountered (" + unk.getFileType() + "): " +
- getPathname(item.getName()));
+ Msg.error(this, "Unsupported folder item encountered (" + unk.getFileType() +
+ "): " + getPathname(item.getName()));
++unknownItemCount;
}
map.put(itemName, item);
@@ -648,9 +651,8 @@ class GhidraFolderData {
"Project folder contains " + nullNameCount + " null items: " + getPathname());
}
if (badItemCount != 0) {
- Msg.error(this,
- "Project folder contains " + unknownItemCount + " unsupported items: " +
- getPathname());
+ Msg.error(this, "Project folder contains " + unknownItemCount + " unsupported items: " +
+ getPathname());
}
return map;
}
@@ -746,7 +748,7 @@ class GhidraFolderData {
* a "folder changed" notification.
* @param recursive if true a recursive refresh will be done (force must also be true).
* Sub-folders will only be refreshed if they have been visited.
- * @param force if true will refresh will be forced regardless
+ * @param force if true, refresh will be forced regardless
* of visited state, if false refresh is lazy and will not be
* performed if a previous refresh set the visited state.
* @param monitor recursion task monitor - break from recursion if cancelled