Merge pull request #31118 from lehasm/alexey-sm-doc-build-stall

This commit is contained in:
Vladimir C 2021-11-08 11:23:26 +03:00 committed by GitHub
commit d15fc85c37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -117,6 +117,9 @@ def build_for_lang(lang, args):
)
)
# Clean to be safe if last build finished abnormally
single_page.remove_temporary_files(lang, args)
raw_config['nav'] = nav.build_docs_nav(lang, args)
cfg = config.load_config(**raw_config)

View File

@ -12,6 +12,7 @@ import test
import util
import website
TEMPORARY_FILE_NAME = 'single.md'
def recursive_values(item):
if isinstance(item, dict):
@ -101,6 +102,14 @@ def concatenate(lang, docs_path, single_page_file, nav):
single_page_file.flush()
def get_temporary_file_name(lang, args):
return os.path.join(args.docs_dir, lang, TEMPORARY_FILE_NAME)
def remove_temporary_files(lang, args):
single_md_path = get_temporary_file_name(lang, args)
if os.path.exists(single_md_path):
os.unlink(single_md_path)
def build_single_page_version(lang, args, nav, cfg):
logging.info(f'Building single page version for {lang}')
@ -109,7 +118,7 @@ def build_single_page_version(lang, args, nav, cfg):
extra['single_page'] = True
extra['is_amp'] = False
single_md_path = os.path.join(args.docs_dir, lang, 'single.md')
single_md_path = get_temporary_file_name(lang, args)
with open(single_md_path, 'w') as single_md:
concatenate(lang, args.docs_dir, single_md, nav)
@ -226,5 +235,4 @@ def build_single_page_version(lang, args, nav, cfg):
logging.info(f'Finished building single page version for {lang}')
if os.path.exists(single_md_path):
os.unlink(single_md_path)
remove_temporary_files(lang, args)