From 6040618ba8f6fb69588ca8219595bc76bb96d9e7 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Thu, 29 Jan 2026 19:18:51 +0100 Subject: only generate file if srcpath is newer than dstpath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- src/gen.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gen.zig') diff --git a/src/gen.zig b/src/gen.zig index fdd33bf..c4d945c 100644 --- a/src/gen.zig +++ b/src/gen.zig @@ -94,8 +94,6 @@ fn genSite(ctx: *Context) !void { const rel_dstpath = try std.fs.path.relative(ctx.allocator(), Context.params.SITE_PATH, dstpath); defer ctx.allocator().free(rel_dstpath); - log.debug("generating {s} at {s}", .{ p, rel_dstpath }); - if (std.fs.path.dirname(rel_dstpath)) |d| { const dstdir = try fs.joinPathAndFilename(ctx.allocator(), &.{Context.params.SITE_PATH}, &.{d}); defer ctx.allocator().free(dstdir); @@ -103,6 +101,12 @@ fn genSite(ctx: *Context) !void { try std.fs.cwd().makePath(dstdir); } + const srcmtime = try fs.getLastEdit(srcpath); + const dstmtime = try fs.getLastEdit(dstpath); + if (srcmtime.sec < dstmtime.sec) continue; + + log.debug("generating {s} at {s}", .{ p, rel_dstpath }); + const f = try fs.FileSwapper.createAt(ctx.allocator(), dstpath); defer f.close(); -- cgit 1.4.1