From 824620ab6ca3326007e67e4753d2dab3af5b59e8 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Sun, 5 Oct 2025 18:32:28 +0200 Subject: runPandoc: use the separate swap api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- src/exe.zig | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/exe.zig b/src/exe.zig index f0d55d4..4d9573e 100644 --- a/src/exe.zig +++ b/src/exe.zig @@ -41,37 +41,37 @@ fn pandocWorker(ctx: *Context, page: []const u8) !void { defer ctx.allocator().free(mtime_str); const f = try fs.FileSwapper.createAt(ctx.allocator(), target_path); + defer f.close(); // open new scope to close the file swapper when we're done writing - { - defer f.close(); - - try f.writer().print( - \\ - \\ - , - .{page}, - ); - - // make pandoc runs reproducable - var env_map = std.process.EnvMap.init(ctx.allocator()); - defer env_map.deinit(); - try env_map.put("SOURCE_DATE_EPOCH", mtime_str); - - try captureStdout(ctx, &.{ - Context.params.PANDOC, - "--from", - "markdown+wikilinks_title_after_pipe+autolink_bare_uris", - "--to", - "html5", - "--lua-filter", - // TODO: embed the preproc filter - Context.params.PANDOC_PREPROC, - "--strip-comments", - "--output=-", - source_path, - }, &env_map, f.writer().any()); - } + try f.writer().print( + \\ + \\ + , + .{page}, + ); + + // make pandoc runs reproducable + var env_map = std.process.EnvMap.init(ctx.allocator()); + defer env_map.deinit(); + try env_map.put("SOURCE_DATE_EPOCH", mtime_str); + + try captureStdout(ctx, &.{ + Context.params.PANDOC, + "--from", + "markdown+wikilinks_title_after_pipe+autolink_bare_uris", + "--to", + "html5", + "--lua-filter", + // TODO: embed the preproc filter + Context.params.PANDOC_PREPROC, + "--strip-comments", + "--output=-", + source_path, + }, &env_map, f.writer().any()); + + // swap now, we want to edit mtime + try f.swap(); // fixup mtime of the resulting file, this has to happen after the file // swapper has been closed, because it works on a tmp file which is going -- cgit 1.4.1