aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/outputs/io_out/source_pod.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sisudoc/outputs/io_out/source_pod.d')
-rw-r--r--src/sisudoc/outputs/io_out/source_pod.d68
1 files changed, 53 insertions, 15 deletions
diff --git a/src/sisudoc/outputs/io_out/source_pod.d b/src/sisudoc/outputs/io_out/source_pod.d
index b32abcd..0ed26db 100644
--- a/src/sisudoc/outputs/io_out/source_pod.d
+++ b/src/sisudoc/outputs/io_out/source_pod.d
@@ -73,13 +73,35 @@ template spinePod() {
assert (doc_matters.src.filename.match(rgx_files.src_fn));
if (doc_matters.opt.action.source_or_pod) {
try {
- /+ ↓ clean slate: remove per-document pod directory before regeneration,
- but only on the first language of a multi-language document,
- so that subsequent languages' files are not wiped +/
+ /+ ↓ clean slate: remove the per-document pod directory before
+ regeneration, but only on the first language of a multi-language
+ document, so that subsequent languages' files are not wiped.
+ .
+ media/abstraction/ is left alone: the .ssp files there are written
+ by the abstraction stage, which runs before this, and for a
+ multi-language document they accumulate one language at a time.
+ That directory clears itself, in the .ssp writer, on the first
+ language of a run.
+ +/
if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[0]) {
string doc_pod_dir = pths_pod.base_filesystem_(doc_matters.src.filename);
+ string keep_dir
+ = pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod.to!string;
if (exists(doc_pod_dir) && doc_pod_dir.isDir) {
- doc_pod_dir.rmdirRecurse;
+ foreach (string _e; dirEntries(doc_pod_dir, SpanMode.shallow)) {
+ if (_e.isDir) {
+ if (keep_dir.startsWith(_e)) { // media/, which holds abstraction/
+ foreach (string _m; dirEntries(_e, SpanMode.shallow)) {
+ if (_m == keep_dir) { continue; }
+ if (_m.isDir) { _m.rmdirRecurse; } else { _m.remove; }
+ }
+ } else {
+ _e.rmdirRecurse;
+ }
+ } else {
+ _e.remove;
+ }
+ }
}
}
{
@@ -208,24 +230,24 @@ template spinePod() {
}
}
}
- } { // bundle abstraction .ssp file (only for --pod2)
+ } { // the abstraction .ssp, written in place by --show-abstraction (only for --pod2)
if (doc_matters.opt.action.pod2) {
- if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { // wait until all language versions of .ssp generated
- import sisudoc.outputs.io_out.paths_output;
- /+ doc_uid_out for any language follows the same pattern, differing
+ if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { // wait until all language versions of .ssp written
+ /+ the .ssp is written straight into pod/<doc>/media/abstraction/,
+ so there is nothing to copy here: it is digested and added to
+ the zip where it stands.
+ doc_uid_out for any language follows the same pattern, differing
only in the trailing ".{lng}". Strip the current language to
- reuse the base across all languages. +/
+ reuse the base across all languages.
+ +/
string _doc_uid_base
= doc_matters.src.doc_uid_out[0 .. $ - doc_matters.src.lng.length];
foreach (_lang; doc_matters.pod.manifest_list_of_languages) { // do for all language versions
- auto out_pth_lng = spineOutPaths!()(doc_matters.output_path, _lang);
- string abstraction_dir = ((out_pth_lng.output_base.chainPath("abstraction")).asNormalizedPath).array;
string ssp_filename = _doc_uid_base ~ _lang ~ ".ssp";
- string fn_src_in = ((abstraction_dir.chainPath(ssp_filename)).asNormalizedPath).array.to!string;
auto fn_src_out_pod_zip_base
= pths_pod.abstraction_root(doc_matters.src.filename).zpod.to!string
~ "/" ~ ssp_filename;
- auto fn_src_out_filesystem
+ auto fn_src_in
= pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod.to!string
~ "/" ~ ssp_filename;
if (exists(fn_src_in)) {
@@ -235,13 +257,26 @@ template spinePod() {
_digests[_lang]["ssp"] ~= file_.sha256hash.toHexString
~ "::" ~ file_.fileSize.to!string ~ " - " ~ ssp_filename ~ "\n";
}
- fn_src_in.copy(fn_src_out_filesystem);
zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip);
} else {
if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt_2) {
writeln("WARNING (io) src out NOT found (abstraction): ", fn_src_in);
}
}
+ /+ ↓ the .ocda.db sits beside the pod rather than inside it: it
+ carries the images itself, and putting it in the zip would
+ store them twice. digested here so that digests.txt covers
+ every artefact the pod directory holds for this document
+ +/
+ {
+ string db_filename = _doc_uid_base ~ _lang ~ ".ocda.db";
+ string fn_db = pths_pod.pod_dir_() ~ "/" ~ db_filename;
+ if (exists(fn_db)) {
+ ST_file_stat file_ = getFileStat(fn_db);
+ _digests[_lang]["ocda_db"] ~= file_.sha256hash.toHexString
+ ~ "::" ~ file_.fileSize.to!string ~ " - " ~ db_filename ~ "\n";
+ }
+ }
}
}
}
@@ -539,7 +574,10 @@ template spinePod() {
f.writeln(_digests[_lang]["ssi"]);
}
if (("ssp" in _digests[_lang]) && (_digests[_lang]["ssp"].length > 0)) {
- f.writeln(_digests[_lang]["ssp"]);
+ f.writeln(_digests[_lang]["ssp"].strip);
+ }
+ if (("ocda_db" in _digests[_lang]) && (_digests[_lang]["ocda_db"].length > 0)) {
+ f.writeln(_digests[_lang]["ocda_db"].strip);
}
}
}