The page cache is one directory per document; the shipped suites measure under a UTF-8 locale (from dev 3321e7c9e36e)
This commit is contained in:
1 parent
d09909a111
commit
73feb007c5
8 files changed
+51
-9
No files matched your search
@@ -1,4 +1,6 @@
|
||||
#include "util.h"
|
||||
#include <functional>
|
||||
#include <sstream>
|
||||
#include "machine.h"
|
||||
#include "error.h"
|
||||
#include "kutil.h"
|
||||
@@ -133,6 +135,30 @@ Document_class::Document_class(Machine& machine) : Klammer_base(machine)
|
||||
}
|
||||
|
||||
|
||||
// The cache directory of ONE document: the target's cache directory
|
||||
// (_latex_files, _html_pages) with a subdirectory per document, named by
|
||||
// the document's stem and a hash of its absolute path. The cache used to
|
||||
// be one directory per target with an entry per chapter BASENAME, shared by
|
||||
// every document on the machine, and freshness is only "the source is
|
||||
// older than the entry": document A's kt/alpha.kt was served document B's
|
||||
// cached alpha whenever B had rendered later -- silently when the chapter
|
||||
// assembled, with B's error message when it did not (TODO 79, 2026-10-19).
|
||||
// The hash, not the path itself: a path can be long and hold any
|
||||
// character; the stem is for the eye. A document given as a string
|
||||
// (ktext -s) has no file and is keyed by the working directory, where its
|
||||
// _text.kt is rewritten on every run.
|
||||
std::string Document_class::document_cache_directory(const std::string& target_cache) const
|
||||
{
|
||||
const fs::path document = m_kt_root_filename.empty()
|
||||
? fs::current_path() / "_string_input"
|
||||
: fs::absolute(fs::path(m_kt_root_filename)).lexically_normal();
|
||||
std::ostringstream key;
|
||||
key << document.stem().string() << "-" << std::hex
|
||||
<< std::hash<std::string>{}(document.generic_string());
|
||||
return cache_directory(target_cache + "/" + key.str());
|
||||
}
|
||||
|
||||
|
||||
void Document_class::save_string_input_as_file()
|
||||
{
|
||||
if (!m_text.empty()) {
|
||||
|
||||
@@ -193,7 +193,10 @@ public:
|
||||
std::vector<std::pair<std::string, std::string>> m_string_components {};
|
||||
std::vector<std::tuple<std::string,std::string,std::string,std::string>> m_toc_components {};
|
||||
|
||||
// The page cache of THIS document under a target's cache directory
|
||||
// (document_class.cpp); set by each target's create_*_output_directories().
|
||||
std::string m_cache_dir {};
|
||||
std::string document_cache_directory(const std::string& target_cache) const;
|
||||
};
|
||||
|
||||
fs::path parse_input_filename(const std::string& s, const std::string& input_dir);
|
||||
|
||||
@@ -190,7 +190,7 @@ std::string Document_class::create_html_output_directories()
|
||||
install_resolved_font(m_resolved_sans, output_directory);
|
||||
install_resolved_font(m_resolved_mono, output_directory);
|
||||
}
|
||||
m_cache_dir = cache_directory("_html_pages");
|
||||
m_cache_dir = document_cache_directory("_html_pages");
|
||||
if (m_no_cache && fs::exists(m_cache_dir)) {
|
||||
for (auto& entry : std::filesystem::directory_iterator(m_cache_dir)) {
|
||||
// What ":cache false" actually removed: a derived consequence of
|
||||
|
||||
@@ -12,7 +12,7 @@ std::string Document_class::create_tex_output_directories()
|
||||
(void)K::log(3);
|
||||
std::string output_directory =
|
||||
absolute_pathname(get("K_output_dir")); // + "/" + get("K_output_basename");
|
||||
m_cache_dir = cache_directory("_latex_files");
|
||||
m_cache_dir = document_cache_directory("_latex_files");
|
||||
if (!m_toc_only) {
|
||||
if (!file_exists(output_directory, false, true)) {
|
||||
fs::create_directory(output_directory);
|
||||
|
||||
Reference in new issue
Block a user