Skip to content
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

Import original data for a source when init is called again #193

Merged
merged 1 commit into from Jan 29, 2015

Conversation

simensen
Copy link
Member

There exists cases where calling init on an existing source would lose data set from previous calls. The problem is that any time a file is asked to be reprocessed (happens when updated as a part of a collection and other hard to track down cases) the metadata would be read in again from the file. The side effect of this is that ONLY the metadata coming in from the frontmatter would remain. Any metadata set by other extensions or other parts of Sculpin core (things like date tracking and auto layout for proxy source collections) would be lost on init.

This patch works by saving a copy of the data before the new metadata is processed. Afterwards, if data was there originally, it imports it on top of the new metdata w/ clobber set to false. This will ensure that data that is already set will not be overwritten by the old data.


Potential Negative Side Effects

This could be a performance issue as we'll be doing import a lot more often than we were before. I don't think I've ever tested that code for performance so this could hurt people with larger sites. Hard to know what impact it might have but it is a thing to consider.

/cc @coderabbi @WyriHaximus @beryllium

There exists cases where calling init on an existing source would lose data set
from previous calls. The problem is that any time a file is asked to be
reprocessed (happens when updated as a part of a collection and other hard to
track down cases) the metadata would be read in again from the file. The side
effect of this is that ONLY the metadata coming in from the frontmatter would
remain. Any metadata set by other extensions or other parts of Sculpin core
(things like date tracking and auto layout for proxy source collections) would
be lost on init.

This patch works by saving a copy of the data before the new metadata is
processed. Afterwards, if data was there originally, it imports it on top of the
new metdata w/ clobber set to `false`. This will ensure that data that is
already set will not be overwritten by the old data.
@WyriHaximus
Copy link
Member

Looks good to me 👍 , not 100% sure how big the performance impact would be though..

simensen added a commit that referenced this pull request Jan 29, 2015
Import original data for a source when init is called again
@simensen simensen merged commit c774c9a into sculpin:master Jan 29, 2015
@simensen simensen deleted the import-previous-data-on-reinit branch January 29, 2015 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants