From ea2b197d1eb9b7125f1ba2c2ae9488d8543901df Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Wed, 11 Mar 2026 21:42:38 +0100 Subject: [PATCH] chore: simplify withDeps signature and fix non-null assertion --- packages/core/src/restic/commands/ls.ts | 10 +++++----- packages/core/src/restic/server.ts | 9 ++------- packages/core/src/utils/common-ancestor.ts | 5 +++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/core/src/restic/commands/ls.ts b/packages/core/src/restic/commands/ls.ts index b4656e56..5d8860a6 100644 --- a/packages/core/src/restic/commands/ls.ts +++ b/packages/core/src/restic/commands/ls.ts @@ -53,12 +53,12 @@ export const ls = async ( config: RepositoryConfig, snapshotId: string, organizationId: string, - path?: string, - options?: { offset?: number; limit?: number }, - deps?: ResticDeps, + path: string | undefined, + options: { offset?: number; limit?: number } | undefined, + deps: ResticDeps, ): Promise => { const repoUrl = buildRepoUrl(config); - const env = await buildEnv(config, organizationId, deps!); + const env = await buildEnv(config, organizationId, deps); const args: string[] = ["--repo", repoUrl, "ls", snapshotId, "--long"]; @@ -119,7 +119,7 @@ export const ls = async ( }, }); - await cleanupTemporaryKeys(env, deps!); + await cleanupTemporaryKeys(env, deps); if (res.exitCode !== 0) { logger.error(`Restic ls failed: ${res.error}`); diff --git a/packages/core/src/restic/server.ts b/packages/core/src/restic/server.ts index 3a188182..88cb7841 100644 --- a/packages/core/src/restic/server.ts +++ b/packages/core/src/restic/server.ts @@ -25,13 +25,8 @@ export { ResticError } from "./error"; function withDeps( command: (...args: [...Args, ResticDeps]) => Result, deps: ResticDeps, -): (...args: Args) => Result; -function withDeps( - command: (...args: [...Args, ResticDeps?]) => Result, - deps: ResticDeps, -): (...args: Args) => Result; -function withDeps(command: (...args: any[]) => any, deps: ResticDeps) { - return (...args: any[]) => command(...args, deps); +): (...args: Args) => Result { + return (...args: Args) => command(...args, deps); } export const createRestic = (deps: ResticDeps) => ({ diff --git a/packages/core/src/utils/common-ancestor.ts b/packages/core/src/utils/common-ancestor.ts index 5f712a60..cfe81ce3 100644 --- a/packages/core/src/utils/common-ancestor.ts +++ b/packages/core/src/utils/common-ancestor.ts @@ -14,8 +14,9 @@ export const findCommonAncestor = (paths: string[]): string => { const commonParts: string[] = []; for (let i = 0; i < minLength; i++) { const partSet = new Set(splitPaths.map((parts) => parts[i])); - if (partSet.size === 1) { - commonParts.push(splitPaths[0]![i]!); + const toPush = splitPaths[0]?.[i]; + if (partSet.size === 1 && toPush) { + commonParts.push(toPush); } else { break; }