mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-04-19 14:28:54 -04:00
Separate include patters and included path cleanly to avoid path with special characters to be expanded. Closes https://github.com/nicotsx/zerobyte/discussions/680 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added ability to select specific directories and paths for inclusion in backup schedules, separate from pattern-based rules. * **Bug Fixes & Improvements** * Automatically migrates existing backup configurations to work with the new path selection system. * Enhanced backup restoration to properly handle both selected paths and pattern-based inclusions. * **Chores** * Updated database schema to support path selections in backup schedules. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import type { BackupSchedule } from "~/client/lib/types";
|
|
import { cronToFormValues } from "../../lib/cron-utils";
|
|
import type { InternalFormValues } from "./types";
|
|
|
|
export const parseMultilineEntries = (value?: string) =>
|
|
value
|
|
? value
|
|
.split("\n")
|
|
.map((entry) => entry.trim())
|
|
.filter(Boolean)
|
|
: [];
|
|
|
|
export const backupScheduleToFormValues = (schedule?: BackupSchedule): InternalFormValues | undefined => {
|
|
if (!schedule) {
|
|
return undefined;
|
|
}
|
|
|
|
const cronValues = cronToFormValues(schedule.cronExpression ?? "0 * * * *");
|
|
|
|
return {
|
|
name: schedule.name,
|
|
repositoryId: schedule.repository.shortId,
|
|
includePaths: schedule.includePaths?.length ? schedule.includePaths : undefined,
|
|
includePatterns: schedule.includePatterns?.length ? schedule.includePatterns.join("\n") : undefined,
|
|
excludePatternsText: schedule.excludePatterns?.join("\n") || undefined,
|
|
excludeIfPresentText: schedule.excludeIfPresent?.join("\n") || undefined,
|
|
oneFileSystem: schedule.oneFileSystem ?? false,
|
|
customResticParamsText: schedule.customResticParams?.join("\n") ?? "",
|
|
...cronValues,
|
|
...schedule.retentionPolicy,
|
|
};
|
|
};
|