Delete structs in DB when deleted in State #320
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing Issue 306
The Problem
As seen in #306 , renaming and deleting of structs does not actually get rid of the toml file which Binsync uses to track structs.
The Solution
In order to make this somewhat generic, I modified the following files;
binsync/core/client.py
binsync/data/state.py
In
state.py
, I introduce thedeleted_artifacts
struct to keep track of any artifact that we want to remove.binsync/binsync/data/state.py
Line 189 in 2af42bd
An example of this being used is in the function
set_struct
which will add an entry like so:binsync/binsync/data/state.py
Lines 505 to 516 in 2af42bd
This then allows us to iterate over the list later on and explicitly all
_delete_data
from the dump function:binsync/binsync/data/state.py
Lines 289 to 301 in 2af42bd
_delete_data
follows the same method as_dump_data
but instead will make use of theremove_data
function inself.client
.The last thing added was in the
client.py
file:binsync/binsync/core/client.py
Line 289 in 2af42bd
This allows us to ignore trying to pass around deleted files or added files and can just update the current folder with
add
. Then when the commit is sent off this will make git also remove the reference so we don't need to manually dorepo.index.remove
.Other Changes
I also updated
binsync/decompilers/ida/hooks.py
to properly passold_name
for the previous name of the changed struct.TODO
The UI table in QT still has the reference for the previous struct for some reason. Despite it being deleted in the folder, it still is present in the table.