Skip to content

Commit 2135304

Browse files
authored
Pass the skip_cache_invalidation flag to symlinks functions (python#178)
Follow-up for b3c3137
1 parent 27b193b commit 2135304

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Diff for: build_docs.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ def save_state(self, build_duration: float):
977977
state_file.write_text(tomlkit.dumps(states), encoding="UTF-8")
978978

979979

980-
def symlink(www_root: Path, language: Language, directory: str, name: str, group: str):
980+
def symlink(www_root: Path, language: Language, directory: str, name: str, group: str, skip_cache_invalidation: bool):
981981
"""Used by major_symlinks and dev_symlink to maintain symlinks."""
982982
if language.tag == "en": # english is rooted on /, no /en/
983983
path = www_root
@@ -993,11 +993,12 @@ def symlink(www_root: Path, language: Language, directory: str, name: str, group
993993
link.unlink()
994994
link.symlink_to(directory)
995995
run(["chown", "-h", ":" + group, str(link)])
996-
purge_path(www_root, link)
996+
if not skip_cache_invalidation:
997+
purge_path(www_root, link)
997998

998999

9991000
def major_symlinks(
1000-
www_root: Path, group, versions: Iterable[Version], languages: Iterable[Language]
1001+
www_root: Path, group, versions: Iterable[Version], languages: Iterable[Language], skip_cache_invalidation: bool
10011002
):
10021003
"""Maintains the /2/ and /3/ symlinks for each languages.
10031004
@@ -1008,11 +1009,11 @@ def major_symlinks(
10081009
"""
10091010
current_stable = Version.current_stable(versions).name
10101011
for language in languages:
1011-
symlink(www_root, language, current_stable, "3", group)
1012-
symlink(www_root, language, "2.7", "2", group)
1012+
symlink(www_root, language, current_stable, "3", group, skip_cache_invalidation)
1013+
symlink(www_root, language, "2.7", "2", group, skip_cache_invalidation)
10131014

10141015

1015-
def dev_symlink(www_root: Path, group, versions, languages):
1016+
def dev_symlink(www_root: Path, group, versions, languages, skip_cache_invalidation: bool):
10161017
"""Maintains the /dev/ symlinks for each languages.
10171018
10181019
Like:
@@ -1022,7 +1023,7 @@ def dev_symlink(www_root: Path, group, versions, languages):
10221023
"""
10231024
current_dev = Version.current_dev(versions).name
10241025
for language in languages:
1025-
symlink(www_root, language, current_dev, "dev", group)
1026+
symlink(www_root, language, current_dev, "dev", group, skip_cache_invalidation)
10261027

10271028

10281029
def purge(*paths):
@@ -1139,8 +1140,8 @@ def build_docs(args) -> bool:
11391140
build_robots_txt(
11401141
versions, languages, args.www_root, args.group, args.skip_cache_invalidation
11411142
)
1142-
major_symlinks(args.www_root, args.group, versions, languages)
1143-
dev_symlink(args.www_root, args.group, versions, languages)
1143+
major_symlinks(args.www_root, args.group, versions, languages, args.skip_cache_invalidation)
1144+
dev_symlink(args.www_root, args.group, versions, languages, args.skip_cache_invalidation)
11441145
proofread_canonicals(args.www_root, args.skip_cache_invalidation)
11451146

11461147
return all_built_successfully

0 commit comments

Comments
 (0)