ci / ci (22, ubuntu-latest) (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
32 lines
832 B
TypeScript
32 lines
832 B
TypeScript
import type { BackupJob } from '../../utils/backup/jobs'
|
|
import { BACKUP_ARCHIVE_EXT } from '../../utils/backup/paths'
|
|
|
|
export function serializeBackupJob(job: BackupJob) {
|
|
const archiveName = job.outputPath
|
|
? job.outputPath.split(/[/\\]/).pop()
|
|
: typeof job.payload.archiveName === 'string'
|
|
? job.payload.archiveName
|
|
: null
|
|
|
|
return {
|
|
id: job.id,
|
|
type: job.type,
|
|
status: job.status,
|
|
progress: job.progress,
|
|
total: job.total,
|
|
message: job.message,
|
|
payload: job.payload,
|
|
outputPath: job.outputPath,
|
|
archiveName,
|
|
downloadable: Boolean(
|
|
job.type === 'full_export'
|
|
&& job.status === 'done'
|
|
&& job.outputPath
|
|
&& archiveName?.endsWith(BACKUP_ARCHIVE_EXT)
|
|
),
|
|
error: job.error,
|
|
createdAt: job.createdAt,
|
|
finishedAt: job.finishedAt
|
|
}
|
|
}
|