mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 01:11:16 +03:00
feat: upload backups
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { debounce } from 'lodash';
|
||||
import { DateTime } from 'luxon';
|
||||
import { stat, writeFile } from 'node:fs/promises';
|
||||
import path, { join } from 'node:path';
|
||||
import { PassThrough, Readable, Writable } from 'node:stream';
|
||||
import { pipeline } from 'node:stream/promises';
|
||||
@@ -269,6 +271,18 @@ export async function listBackups({
|
||||
};
|
||||
}
|
||||
|
||||
export async function uploadBackup(file: Express.Multer.File): Promise<void> {
|
||||
const backupsFolder = StorageCore.getBaseFolder(StorageFolder.Backups);
|
||||
const path = join(backupsFolder, file.originalname);
|
||||
|
||||
try {
|
||||
await stat(path);
|
||||
throw new BadRequestException('File already exists!');
|
||||
} catch {
|
||||
await writeFile(path, file.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
function createSqlProgressStreams(cb: (progress: number) => void) {
|
||||
const STDIN_START_MARKER = new TextEncoder().encode('FROM stdin');
|
||||
const STDIN_END_MARKER = new TextEncoder().encode(String.raw`\.`);
|
||||
|
||||
Reference in New Issue
Block a user