For the record, unfortunately this script didn't fix the issue - it
still wasn't happy.I had to convert to .leo xml and then back to .db. 
I think there's still a lot of value in fixing the DB format, but
hopefully in a way that won't limit it's potential performance.


On Fri, 2020-09-04 at 02:52 -0700, vitalije 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.
> 
> 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)
> 
> 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.
> 
> 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.
> 
> Vitalije
> 
> 
> 
> 
> -- 
> 
> You received this message because you are subscribed to a topic in
> the Google Groups "leo-editor" group.
> 
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/leo-editor/sANduRjZDVI/unsubscribe.
> 
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/leo-editor/56aa7952-a09d-4da5-b176-206916448e26o%40googlegroups.com
> .
> 

-- 
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/8b75432c2bbc5e959d821b7a3244813cc5672431.camel%40gmail.com.

Reply via email to