From 52172bfadb5d5f38a0e952aed5a53f545cb7419f Mon Sep 17 00:00:00 2001 From: Mitchell Date: Sat, 29 Aug 2026 10:22:54 -0500 Subject: [PATCH] fix: create output directories lazily, not at startup closes #151 --- build.zig.zon | 2 +- src/util.zig | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 00c6ce8..636a7f1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .spacecap, - .version = "0.5.0", + .version = "0.6.0", .fingerprint = 0xdc2511c12abe6e80, .minimum_zig_version = "0.17.0", .dependencies = .{ diff --git a/src/util.zig b/src/util.zig index 1125eb9..62c3979 100644 --- a/src/util.zig +++ b/src/util.zig @@ -323,9 +323,10 @@ pub const OutputDirectoryType = enum { videos, }; -// Falls back to the current working directory when -// the home-based output directory cannot be resolved or created. -// Caller owns the memory. +/// Caller owns memory and must free. +/// Falls back to the current working directory when the home output directory +/// cannot be resolved. +/// NOTE: this does not create the directory or ensure it exists. pub fn get_default_output_dir( allocator: std.mem.Allocator, io: std.Io, @@ -356,15 +357,7 @@ pub fn get_default_output_dir( .pictures => "Pictures", .videos => "Videos", }; - const output_dir = try std.fs.path.join(allocator, &.{ _home_dir, home_subdirectory, "spacecap" }); - errdefer allocator.free(output_dir); - - if (std.Io.Dir.cwd().createDirPath(io, output_dir)) { - return output_dir; - } else |err| { - log.err("[get_default_output_dir] failed to create output directory {s}: {}", .{ output_dir, err }); - allocator.free(output_dir); - } + return std.fs.path.join(allocator, &.{ _home_dir, home_subdirectory, "spacecap" }); } log.warn("[get_default_output_dir] falling back to current working directory", .{});