acd_cli icon indicating copy to clipboard operation
acd_cli copied to clipboard

How to purge dangling parents?

Open legnaleurc opened this issue 7 years ago • 2 comments

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.

legnaleurc avatar May 30 '17 23:05 legnaleurc

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?

bgemmill avatar May 31 '17 00:05 bgemmill

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.

legnaleurc avatar May 31 '17 06:05 legnaleurc