refactor: also move negated patterns to includePatterns
This commit is contained in:
parent
186cb4f01f
commit
a25b719724
1 changed files with 3 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ import { db } from "../../../db/db";
|
||||||
import { backupSchedulesTable } from "../../../db/schema";
|
import { backupSchedulesTable } from "../../../db/schema";
|
||||||
import { toMessage } from "~/server/utils/errors";
|
import { toMessage } from "~/server/utils/errors";
|
||||||
|
|
||||||
const isGlobPattern = (value: string) => /[*?[\]]/.test(value);
|
export const isIncludePatternEntry = (value: string) => value.startsWith("!") || /[*?[\]]/.test(value);
|
||||||
|
|
||||||
const execute = async () => {
|
const execute = async () => {
|
||||||
const errors: Array<{ name: string; error: string }> = [];
|
const errors: Array<{ name: string; error: string }> = [];
|
||||||
|
|
@ -18,12 +18,12 @@ const execute = async () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const existingIncludePatterns = schedule.includePatterns ?? [];
|
const existingIncludePatterns = schedule.includePatterns ?? [];
|
||||||
const includePaths = existingIncludePatterns.filter((value) => !isGlobPattern(value));
|
const includePaths = existingIncludePatterns.filter((value) => !isIncludePatternEntry(value));
|
||||||
if (includePaths.length === 0) {
|
if (includePaths.length === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const includePatterns = existingIncludePatterns.filter(isGlobPattern);
|
const includePatterns = existingIncludePatterns.filter(isIncludePatternEntry);
|
||||||
|
|
||||||
await db
|
await db
|
||||||
.update(backupSchedulesTable)
|
.update(backupSchedulesTable)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue