Skip to content

Pass the skip_cache_invalidation flag to symlinks functions #178

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

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def save_state(self, build_duration: float):
state_file.write_text(tomlkit.dumps(states), encoding="UTF-8")


def symlink(www_root: Path, language: Language, directory: str, name: str, group: str):
def symlink(www_root: Path, language: Language, directory: str, name: str, group: str, skip_cache_invalidation: bool):
"""Used by major_symlinks and dev_symlink to maintain symlinks."""
if language.tag == "en": # english is rooted on /, no /en/
path = www_root
Expand All @@ -991,11 +991,12 @@ def symlink(www_root: Path, language: Language, directory: str, name: str, group
link.unlink()
link.symlink_to(directory)
run(["chown", "-h", ":" + group, str(link)])
purge_path(www_root, link)
if not skip_cache_invalidation:
purge_path(www_root, link)


def major_symlinks(
www_root: Path, group, versions: Iterable[Version], languages: Iterable[Language]
www_root: Path, group, versions: Iterable[Version], languages: Iterable[Language], skip_cache_invalidation: bool
):
"""Maintains the /2/ and /3/ symlinks for each languages.

Expand All @@ -1006,11 +1007,11 @@ def major_symlinks(
"""
current_stable = Version.current_stable(versions).name
for language in languages:
symlink(www_root, language, current_stable, "3", group)
symlink(www_root, language, "2.7", "2", group)
symlink(www_root, language, current_stable, "3", group, skip_cache_invalidation)
symlink(www_root, language, "2.7", "2", group, skip_cache_invalidation)


def dev_symlink(www_root: Path, group, versions, languages):
def dev_symlink(www_root: Path, group, versions, languages, skip_cache_invalidation: bool):
"""Maintains the /dev/ symlinks for each languages.

Like:
Expand All @@ -1020,7 +1021,7 @@ def dev_symlink(www_root: Path, group, versions, languages):
"""
current_dev = Version.current_dev(versions).name
for language in languages:
symlink(www_root, language, current_dev, "dev", group)
symlink(www_root, language, current_dev, "dev", group, skip_cache_invalidation)


def purge(*paths):
Expand Down Expand Up @@ -1137,8 +1138,8 @@ def build_docs(args) -> bool:
build_robots_txt(
versions, languages, args.www_root, args.group, args.skip_cache_invalidation
)
major_symlinks(args.www_root, args.group, versions, languages)
dev_symlink(args.www_root, args.group, versions, languages)
major_symlinks(args.www_root, args.group, versions, languages, args.skip_cache_invalidation)
dev_symlink(args.www_root, args.group, versions, languages, args.skip_cache_invalidation)
proofread_canonicals(args.www_root, args.skip_cache_invalidation)

return all_built_successfully
Expand Down