forked from r.muellner/velum-raycast
feat: run Velum project jobs in the background and process DOCX locally
This commit is contained in:
@@ -16,7 +16,7 @@ export type { ProjectWhitelistEntry } from "./project-whitelist";
|
||||
export type ProjectRule = { type: "BEGRIFF" | "PERSON" | "ORG" | "ORT" | "FIRMA" | "KUNDE"; value: string };
|
||||
export type ProjectFile = { relPath: string; absPath: string; kind: "text" | "document"; size: number };
|
||||
export type SkippedProjectFile = { path: string; reason: string };
|
||||
export type RunFile = { source: string; output: string; kind: ProjectFile["kind"]; imageReport?: DocumentImageReport };
|
||||
export type RunFile = { source: string; output: string; kind: ProjectFile["kind"]; imageReport?: DocumentImageReport; localDocx?: true };
|
||||
export type ProjectRun = {
|
||||
version: 2;
|
||||
origin?: "direct" | "imported";
|
||||
@@ -236,7 +236,7 @@ export function forceMasks(rules: ProjectRule[]): Record<string, string[]> {
|
||||
}
|
||||
|
||||
export async function scanProjectFiles(root: string, maxSize?: number,
|
||||
validateText = true): Promise<{
|
||||
validateText = true, documentLimits: Readonly<Record<string, number>> = {}): Promise<{
|
||||
files: ProjectFile[]; skipped: SkippedProjectFile[];
|
||||
}> {
|
||||
const files: ProjectFile[] = [];
|
||||
@@ -263,7 +263,8 @@ export async function scanProjectFiles(root: string, maxSize?: number,
|
||||
}
|
||||
const stat = await fs.stat(path);
|
||||
const kind = DOCUMENTS.has(extname(path).toLowerCase()) ? "document" : "text";
|
||||
const limit = maxSize ?? (kind === "document" ? 20 * 1024 * 1024 : Number.POSITIVE_INFINITY);
|
||||
const limit = maxSize ?? (kind === "document"
|
||||
? documentLimits[extname(path).toLowerCase()] ?? 20 * 1024 * 1024 : Number.POSITIVE_INFINITY);
|
||||
if (stat.size > limit) { skip(relPath, `Datei zu groß (Grenze: ${limit / 1024 / 1024} MiB)`); continue; }
|
||||
if (kind === "document" && extname(path).toLowerCase() !== ".pdf" && !(await isOfficeArchive(path))) {
|
||||
skip(relPath, "Kein lesbares Office-ZIP-Archiv (beschädigt, verschlüsselt oder falsche Endung)");
|
||||
@@ -533,7 +534,8 @@ export async function scanRestorableCopyFiles(run: ProjectRun, directory: string
|
||||
root = join(directory, "files");
|
||||
}
|
||||
}
|
||||
const scan = await scanProjectFiles(root);
|
||||
// XLSX restoration runs locally as a stream and does not upload the file.
|
||||
const scan = await scanProjectFiles(root, undefined, true, { ".xlsx": Number.POSITIVE_INFINITY });
|
||||
const files = scan.files.filter((file) => file.kind === "text" || isRestorableDocument(file.relPath));
|
||||
return { root, files, skipped: scan.skipped.length + scan.files.length - files.length };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user