Skip to content

Commit

Permalink
On sync_checkout, delete disabled pages
Browse files Browse the repository at this point in the history
Now if the sidecar for a notebook marks a page as disabled, the page
won't be executed and if it already existed, it'll be marked for
soft-deletion.
  • Loading branch information
jonathansick committed Apr 18, 2023
1 parent b8993ec commit 883102e
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/timessquare/services/github/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ async def sync_checkout(
different.
2. If new, create the page.
3. If changed, modify the existing page
4. If disabled, mark the page for deletion.
3. Delete any pages not found in the repository checkout.
"""
Expand Down Expand Up @@ -262,13 +263,29 @@ async def sync_checkout(
or notebook.sidecar_git_tree_sha
!= page.repository_sidecar_sha
):
self._logger.debug(
"Notebook content has updated",
display_path=display_path,
)
await self.update_page(
notebook=notebook, page=existing_pages[display_path]
)
if notebook.sidecar.enabled is False:
self._logger.debug(
"Notebook is disabled. Dropping from update.",
display_path=display_path,
)
try:
found_display_paths.remove(display_path)
except ValueError:
self._logger.debug(
"Tried to delete existing page, now disabled, "
"but it was not in found_display_paths.",
display_path=display_path,
found_display_paths=found_display_paths,
)
else:
self._logger.debug(
"Notebook content has updated",
display_path=display_path,
)
await self.update_page(
notebook=notebook,
page=existing_pages[display_path],
)
else:
self._logger.debug(
"Notebook content is the same; skipping",
Expand Down

0 comments on commit 883102e

Please sign in to comment.