quak backup: print the date and time a run starts and finishes (closes #245)
check / check (push) Waiting to run

Adds a `Started at` line after `Starting backup...` and a `Finished at`
line after `--- Backup complete ---`, in local time with the UTC offset.
No existing line changes. The clock comes in through `CliContext.now`.

The README's crontab now pipes the output to `logger`, which adds its own
time to each line; appending to a file remains as the alternative.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-19 06:48:42 +00:00
1 parent 2492946e9d
commit ab236dc162
6 files changed
+121 -16

No files matched your search

+17 -2
View File
@@ -77,8 +77,17 @@ const PASSWORD = "backup-password";
const USER_ID = 42;
const FRIEND_ID = 99;
// Noon on 1 March 2024 in the time zone of the machine running the test, the
// one quak dates save paths in, in microseconds, as Ente records times.
// quak prints the time a backup starts, and dates save paths, in local time.
// The zone is pinned here, before any fixture is dated, and restored after
// the last test.
const savedTZ = process.env.TZ;
process.env.TZ = "Europe/Berlin";
// The time every backup's clock reads, 03:30 in Berlin.
const NOW = new Date(Date.UTC(2026, 10, 11, 2, 30));
const STARTED = "Started at 2026-11-11 03:30:00 +0100\n";
// Noon on 1 March 2024 in local time, the one quak dates save paths in, in
// microseconds, as Ente records times.
const TAKEN = new Date(2024, 2, 1, 12).getTime() * 1000;
// The date folder every original is saved in.
const DAY = "2024/2024-03/2024-03-01";
@@ -278,6 +287,8 @@ beforeAll(async () => {
afterAll(() => {
rmSync(root, { recursive: true, force: true });
if (savedTZ === undefined) delete process.env.TZ;
else process.env.TZ = savedTZ;
});
// Run `quak backup <dir>` as `bin/quak.ts` runs it, sending its requests
@@ -326,6 +337,7 @@ const backup = async (
login: prompted,
prompt: prompted,
promptSecret: prompted,
now: () => NOW,
};
const code = await new Promise<number>((resolve) => {
void run(backupCommand(ctx, dir, opts), stdout, stderr, log, resolve);
@@ -698,6 +710,7 @@ describe("quak backup", () => {
expect(code).toBe(3);
expect(stderr).toBe(
"Starting backup...\n" +
STARTED +
"Refreshing library...\n" +
`quak: the saved session is no longer valid; run "quak login"\n`,
);
@@ -725,6 +738,7 @@ describe("quak backup", () => {
expect(code).toBe(1);
expect(stderr).toBe(
"Starting backup...\n" +
STARTED +
"Refreshing library...\n" +
`quak: ${reason}\n`,
);
@@ -1117,6 +1131,7 @@ describe("a backup whose lock is lost", () => {
expect(code).toBe(1);
expect(stderr).toBe(
"Starting backup...\n" +
STARTED +
"Fetched the files of 1 of 3 collections\n" +
"Fetched the files of 2 of 3 collections\n" +
"Fetched the files of 3 of 3 collections\n" +