Skip to content

Commit

Permalink
Register source_obj as dependency for all artifacts (that have one)
Browse files Browse the repository at this point in the history
  • Loading branch information
dairiki committed Mar 1, 2022
1 parent a99b93f commit f6769f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lektor/build_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from lektor.assets import Directory
from lektor.assets import File
from lektor.constants import PRIMARY_ALT
from lektor.context import get_ctx
from lektor.db import Attachment
from lektor.db import Page
from lektor.exception import LektorException
Expand Down Expand Up @@ -177,9 +176,8 @@ def produce_artifacts(self):
)

def build_artifact(self, artifact):
# Record dependecies on all our sources and datamodel
get_ctx().track_source_dependency(self.source)

# FIXME: This check should probably be moved into Artifact so that it
# is applied for all artifacts, not just those built from Pages.
try:
self.source.url_path.encode("ascii")
except UnicodeError as error:
Expand Down
12 changes: 10 additions & 2 deletions lektor/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,12 @@ def __repr__(self):


class Artifact:
"""This class represents a build artifact."""
"""This class represents a build artifact.
:param sources: The _primary sources_ for the artifact.
If none of the primary sources for an artifact exist, the artifact
will be considered obsolete and will be deleted at the next pruning.
"""

def __init__(
self,
Expand Down Expand Up @@ -933,8 +938,11 @@ def update(self):
"""
ctx = self.begin_update()
try:
if self.source_obj:
# Record dependencies on all sources and datamodel
ctx.track_source_dependency(self.source_obj)
yield ctx
except: # pylint: disable=bare-except # noqa
except BaseException:
exc_info = sys.exc_info()
self.finish_update(ctx, exc_info)
else:
Expand Down

0 comments on commit f6769f3

Please sign in to comment.