It turns out my inconsistency issues were all from a single missed file handle close

This commit is contained in:
Tangent / Rose / Nebula Rosa 2024-11-07 17:30:59 -07:00
parent fd4a164e95
commit 9eb20662ce

View File

@ -229,12 +229,12 @@ local function concatenate_pages(config)
section_file:write("\n") -- guarantees no accidental line collisions section_file:write("\n") -- guarantees no accidental line collisions
page_file:close() page_file:close()
end end
section_file:close()
end end
end end
local function write_markdown_file(config) local function write_markdown_file(config)
local working_dir = get_base_file_name(config) local working_dir = get_base_file_name(config)
os.execute("sleep 1") -- fix race condition from the previous command
local markdown_file, err = io.open(get_base_file_name(config) .. ".md", "w") local markdown_file, err = io.open(get_base_file_name(config) .. ".md", "w")
if not markdown_file then error(err) end if not markdown_file then error(err) end
@ -256,7 +256,7 @@ local function write_markdown_file(config)
section_file:close() section_file:close()
end end
markdown_file:write("# Ebook Creation Metadata\n\n") markdown_file:write("\n\n# Ebook Creation Metadata\n\n")
markdown_file:write(copyright_warning) markdown_file:write(copyright_warning)
markdown_file:write("This ebook was created using the following config:\n\n") markdown_file:write("This ebook was created using the following config:\n\n")
markdown_file:write("```json\n" .. config.config_file_text .. "\n```\n") markdown_file:write("```json\n" .. config.config_file_text .. "\n```\n")