New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account for sparse vertex lists #432
Conversation
Because any vertex may be removed from the graph at any time, the array that describes the vertex-to-index mapping may be sparse. Generate an array with nil values in place of removed vertices.
This bug causes redundant compilation, so a higher-level test may be appropriate. |
Hmm, I get the feeling there's an underlying issue here. I have access to your site source, so I’ll take a look. |
Hey @ddfreyne. I think this is a bug in nanoc. Let me explain The # example internal @vertices data structure
{
1 => [:item, 'example1'],
3 => [:item, 'example3']
} The computed # example edges as computed by `DirectedGraph#edges`
[
[1, 3],
[3, 1]
] So far so good. The problem comes when # example vertices as computed by `DirectedGraph#vertices
[
[:item, 'example1'],
[:item, 'example3']
] When |
Oh wow, that is a nasty issue. Thanks for the detailed analysis! Where are you removing items? Explicitly in the preprocess block? |
I'm not explicitly removing any items. I guess I'll have to dig around in my site's layouts for suspicious inlined Ruby... |
To make this process a little easier, I made the following change: diff --git a/Rules b/Rules
index c522a62..fc55774 100755
--- a/Rules
+++ b/Rules
# preprocess lets you access the @items array before any compilation
preprocess do
+ @items.freeze This immediately failed because I am currently (intentionally) creating new items to model "categories" on my site. I commented out the lines that push new "category" items into the Is my approach to detecting item removal sound? With this change, is there any other way that my code could be removing items? |
Yep, @items.freeze will prevent modifications at all. Can you try using the |
I’m getting the feeling that we’re on the wrong track with the item removal idea… nanoc calculates outdated items recursively, so a single compilation should find everything. I’ll play around with the site source (I have access to it) later today and see what I can find out! |
Sweet, good to know this got resolved! |
Because any vertex may be removed from the graph at any time, the array
that describes the vertex-to-index mapping may be sparse. Generate an
array with nil values in place of removed vertices.