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 -->
17 lines
577 B
TypeScript
17 lines
577 B
TypeScript
import fs from "node:fs/promises";
|
|
import { RESTIC_PASS_FILE } from "~/server/core/constants";
|
|
import type { ResticEnv } from "../types";
|
|
|
|
export const cleanupTemporaryKeys = async (env: ResticEnv) => {
|
|
const keysToClean = ["_SFTP_KEY_PATH", "_SFTP_KNOWN_HOSTS_PATH", "RESTIC_CACERT", "GOOGLE_APPLICATION_CREDENTIALS"];
|
|
|
|
for (const key of keysToClean) {
|
|
if (env[key]) {
|
|
await fs.unlink(env[key]).catch(() => {});
|
|
}
|
|
}
|
|
|
|
if (env.RESTIC_PASSWORD_FILE && env.RESTIC_PASSWORD_FILE !== RESTIC_PASS_FILE) {
|
|
await fs.unlink(env.RESTIC_PASSWORD_FILE).catch(() => {});
|
|
}
|
|
};
|