zerobyte/app/server/utils/restic/helpers/add-common-args.ts
Nico 4a812a884b
refactor(restic): split each command into its own file (#584)
refactor(restic): split each command into its own file

refactor: add missing await before promise expects

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

## Release Notes

* **Tests**
  * Improved async assertion handling across test suites for enhanced test reliability
  * Expanded test coverage for backup, restore, and other core operations

* **Refactor**
  * Reorganized internal utility structure for improved code maintainability

* **Chores**
  * Updated linting configuration and TypeScript dependencies

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-26 19:51:24 +01:00

42 lines
1 KiB
TypeScript

import type { RepositoryConfig } from "~/schemas/restic";
import { formatBandwidthLimit } from "./bandwidth";
import type { ResticEnv } from "../types";
export const addCommonArgs = (
args: string[],
env: ResticEnv,
config?: RepositoryConfig,
options?: { skipBandwidth?: boolean; includeJson?: boolean },
) => {
if (options?.includeJson !== false) {
args.push("--json");
}
if (env._SFTP_SSH_ARGS) {
args.push("-o", `sftp.args=${env._SFTP_SSH_ARGS}`);
}
if (env.AWS_S3_BUCKET_LOOKUP === "dns") {
args.push("-o", "s3.bucket-lookup=dns");
}
if (env._INSECURE_TLS === "true") {
args.push("--insecure-tls");
}
if (env.RESTIC_CACERT) {
args.push("--cacert", env.RESTIC_CACERT);
}
if (config && !options?.skipBandwidth) {
const uploadLimit = formatBandwidthLimit(config.uploadLimit);
if (uploadLimit) {
args.push("--limit-upload", uploadLimit);
}
const downloadLimit = formatBandwidthLimit(config.downloadLimit);
if (downloadLimit) {
args.push("--limit-download", downloadLimit);
}
}
};