runBackup rejects a contentConcurrency that is not a positive integer

A library object whose contentConcurrency was missing, 0 or negative
started no worker, so the backup stored no original, dropped the earlier
entries of failures.json and reported no error. runBackup now throws a
RangeError for any limit that is not a positive integer, as BoundedPool
does, before it takes the lock.

Model: opus-5-5
This commit is contained in:
2026-10-14 06:34:09 +00:00
parent 4dc9e9e23c
commit 65b0de4694
+8
View File
@@ -972,6 +972,14 @@ export const runBackup = async (
"open the library with one)", "open the library with one)",
); );
} }
// As `BoundedPool` does. A limit below 1, or one that is not a number,
// would back up no original and end with no error.
const { contentConcurrency } = lib;
if (!Number.isInteger(contentConcurrency) || contentConcurrency < 1) {
throw new RangeError(
`contentConcurrency must be a positive integer, got ${contentConcurrency}`,
);
}
if (opts.lock) { if (opts.lock) {
return runLockedBackup(lib, opts, downloadDirectory, opts.lock); return runLockedBackup(lib, opts, downloadDirectory, opts.lock);
} }