fix: backup restore formatting

This commit is contained in:
Eli Bosley
2025-01-28 15:01:01 -05:00
parent 8d905974be
commit 0cfdd5a61b

View File

@@ -1,6 +1,7 @@
import { BadRequestException, ExecutionContext, Logger, UnauthorizedException } from '@nestjs/common'; import { BadRequestException, ExecutionContext, Logger, UnauthorizedException } from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql'; import { GqlExecutionContext } from '@nestjs/graphql';
import { copyFile, unlink } from 'node:fs/promises'; import { access, constants, copyFile, unlink } from 'node:fs/promises';
import { dirname } from 'node:path';
import strftime from 'strftime'; import strftime from 'strftime';
@@ -245,9 +246,6 @@ export function handleAuthError(
throw new UnauthorizedException(`${operation}: ${errorMessage}`); throw new UnauthorizedException(`${operation}: ${errorMessage}`);
} }
import { access, constants } from 'node:fs/promises';
import { dirname } from 'node:path';
/** /**
* Helper method to allow backing up a single file to a .bak file. * Helper method to allow backing up a single file to a .bak file.
* @param path the file to backup, creates a .bak file in the same directory * @param path the file to backup, creates a .bak file in the same directory
@@ -275,8 +273,8 @@ export const backupFile = async (path: string, throwOnMissing = true): Promise<v
error.code === 'ENOENT' error.code === 'ENOENT'
? `File does not exist: ${path}` ? `File does not exist: ${path}`
: error.code === 'EACCES' : error.code === 'EACCES'
? `Permission denied: ${path}` ? `Permission denied: ${path}`
: `Failed to backup file: ${error.message}` : `Failed to backup file: ${error.message}`
); );
} }
} }
@@ -312,8 +310,8 @@ export const restoreFile = async (path: string, throwOnMissing = true): Promise<
error.code === 'ENOENT' error.code === 'ENOENT'
? `Backup file does not exist: ${backupPath}` ? `Backup file does not exist: ${backupPath}`
: error.code === 'EACCES' : error.code === 'EACCES'
? `Permission denied: ${path}` ? `Permission denied: ${path}`
: `Failed to restore file: ${error.message}` : `Failed to restore file: ${error.message}`
); );
} }
return false; return false;