diff options
author | wrmr | 2025-06-24 18:02:40 -0400 |
---|---|---|
committer | wrmr | 2025-06-24 18:02:40 -0400 |
commit | 64ab323602f4b2d2f4b9f54dca4f67f0ede1aaac (patch) | |
tree | 00fef81474289c790ce51da17fd8af3917da23ca | |
parent | 3ac481da3fdf4a614abf2fa50ee642df12fdd0f0 (diff) |
fix weird time travel behavior
-rw-r--r-- | main.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/main.c b/main.c index 40d861e..988935d 100644 --- a/main.c +++ b/main.c @@ -391,13 +391,13 @@ void ensure_dotbink_exists(Arena *temp) { void new_post(Arena *temp) { struct timespec ts; - if (clock_gettime(CLOCK_REALTIME, &ts)) { - err(1, "clock_gettime failure"); - } - Str t = str_fmt(temp, "%U%09U", (uint64_t)ts.tv_sec, (uint64_t)ts.tv_nsec); - const char *tmpf = cstr_fmt(temp, "/tmp/cbink_%s_%S.txt", getlogin(), t); - const char *outf = cstr_fmt(temp, "/home/%s/.bink/%S", getlogin(), t); + /* create and edit post in a temp file */ + + if (clock_gettime(CLOCK_REALTIME, &ts)) err(1, "clock_gettime failure"); + + const char *tmpf = cstr_fmt(temp, "/tmp/cbink_%s_%U%09u.txt", getlogin(), + (uint64_t)ts.tv_sec, (uint32_t)ts.tv_nsec); if (system(cstr_fmt(temp, "%s %s", get_editor(), tmpf))) return; Str body = { 0 }; @@ -413,6 +413,12 @@ void new_post(Arena *temp) { body = str_trim(body); if (body.n < 1) return; + /* write it to .bink (with updated timestamp) */ + + if (clock_gettime(CLOCK_REALTIME, &ts)) err(1, "clock_gettime failure"); + + const char *outf = cstr_fmt(temp, "/home/%s/.bink/%U%09u", getlogin(), + (uint64_t)ts.tv_sec, (uint32_t)ts.tv_nsec); f = fopen(outf, "w/o"); if (!f) { log_warn("failed to open %s", outf); |