acd_cli
acd_cli copied to clipboard
How to purge dangling parents?
I'm not sure how to reproduce this, but I have some nodes which have dangling parents, i.e. the ID does not exists in nodes
table.
I think if we alter the table parentage
's key parent
to FOREIGN KEY(parent) REFERENCES nodes (id)
could solve/detect this problem, since the folders
table has been removed from schema version 2.
I did the schema change you mentioned a while back in #374, but the larger issue is that the nodes table is just missing a value. Have you had successful a successful sync before running into this?
I think so. It will show Root node not found. Sync may have been incomplete.
warning at the first time sync, but succeed at the second run.
I also dumped changes list into a file, and it indicates that it added a node, but its parent does not exists anywhere.
These nodes will break some functions, because when we attempt to do cache.first_path(node_id)
, it always fail.
If the tables are supposed to reflect what changes list do, we could probably add a function detect orphan nodes, and let users decide how to fix them.