diff options
| author | Robert Günzler <r@gnzler.io> | 2026-01-29 19:18:51 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-01-29 21:38:25 +0100 |
| commit | 6040618ba8f6fb69588ca8219595bc76bb96d9e7 (patch) | |
| tree | e0419a5e6117f550206f0728457d5ba6e6e5efb1 | |
| parent | b89d00db159328a28a77f24a8bcb1fd29e08e63e (diff) | |
| download | site-6040618ba8f6fb69588ca8219595bc76bb96d9e7.tar.gz | |
only generate file if srcpath is newer than dstpath
Signed-off-by: Robert Günzler <r@gnzler.io>
| -rw-r--r-- | src/gen.zig | 8 |
1 files changed, 6 insertions, 2 deletions
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(); |