On Fri, Sep 4, 2020 at 4:52 AM vitalije <[email protected]> wrote:

>
>> My *tentative* conclusion is that there may be a bug in
>> fc.retrieveVnodesFromDb. However, there are no special cases in this code,
>> so what the bug could possibly be is a big mystery. Iirc, Vitalije wrote
>> this code. Any insights would be appreciated.
>>
>>
> I am almost 100% sure that the fc.retrieveVnodesFromDb works correctly. It
> just restores outline from the rows retrieved from db. Saving and loading
> from db work in tandem. If the outline being saved has broken links, then
> the outline loaded afterwards will have broken links too.
>

This seems like the most likely explanation to me as well.

Most likely outline got broken links during some modification and later was
> saved as such.
>
> Here is a script that can fix broken links:
> from collections import defaultdict
> def relink_outline(c):
>     '''Normalizes outline fixing broken links'''
>     parDict = defaultdict(list)
>     for p in c.all_positions():
>         parDict[p.gnx].append(p._parentVnode())
>     gnx2v = c.fileCommands.gnxDict
>     for gnx, parents in parDict.items():
>         v = gnx2v[gnx]
>         v.parents = parents
>     c.checkOutline()
> relink_outline(c)
>
Thanks for this script.   It should be possible for c.checkOutline to catch
the kinds of problems we have been discussing.  It could even compare the
links before and after running relink_outline!

When saving to xml information about parent links is omitted. When loading
> from xml file, correct parent links are infered again. Perhaps I can change
> writing to db to omitt parent links and just infer them when loading from
> db.
>

Interesting. Please let us know what you conclude.

It is still a mistery how k-hen got his outline to this invalid state. My
> guess is that it was caused during the updating clones in both @file files
> and @nosent files. That would explain why we haven't noticed this bug
> before. It is not very common to have shared clones in both @nosent and
> @file files.
>

Yes, it's still a mystery. Many thanks for your helpful and insightful
comments.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS2jPGq-Pvpc%3DyxW-zyQvrhTc7CQpLns-%3De1fkRq5gg-Ew%40mail.gmail.com.

Reply via email to