fix: allow rerunning imported projects
This commit is contained in:
@@ -101,10 +101,8 @@ async function prepare(root: string, files: ProjectFile[], rules: ProjectRule[],
|
||||
const masks = forceMasks(withoutWhitelistedRules(rules, whitelist));
|
||||
const latestEntry = (await listRuns(root))[0];
|
||||
const latest = latestEntry?.run;
|
||||
if (latest?.origin === "imported") {
|
||||
throw new Error("Dieser Quellordner enthält bereits pseudonymisierte Dateien. Für einen neuen Lauf bitte einen Klartext-Quellordner wählen.");
|
||||
}
|
||||
const previousMapping: PlaceholderMapping = latest?.mapping ?? {};
|
||||
const previousPlaceholders = Object.keys(previousMapping);
|
||||
let mapping: PlaceholderMapping = previousMapping;
|
||||
const drafts: Draft[] = [];
|
||||
const retained: Preview["retained"] = [];
|
||||
@@ -112,6 +110,8 @@ async function prepare(root: string, files: ProjectFile[], rules: ProjectRule[],
|
||||
const hits: Hit[] = [];
|
||||
const texts = new Map<string, string>();
|
||||
const sourceInPlace = Boolean(latest?.inPlace || latest?.sourceInPlace);
|
||||
// A migrated snapshot may differ from the source folder. Recheck its files
|
||||
// unless an earlier run actually replaced them in place.
|
||||
const previousOutputs = new Set(sourceInPlace ? latest?.files.map((file) => file.output) : []);
|
||||
const previousDirectory = latestEntry?.directory;
|
||||
for (const file of files) {
|
||||
@@ -131,7 +131,7 @@ async function prepare(root: string, files: ProjectFile[], rules: ProjectRule[],
|
||||
if (file.kind === "text") texts.set(file.relPath, textFromBytes(data));
|
||||
}
|
||||
const addHits = (draft: Draft, found: Hit[]) => {
|
||||
draft.hits = withoutWhitelistedHits(withoutPlaceholderHits(found), whitelist);
|
||||
draft.hits = withoutWhitelistedHits(withoutPlaceholderHits(found, previousPlaceholders), whitelist);
|
||||
hits.push(...draft.hits);
|
||||
if (hits.length > MAX_REVIEW_HITS) throw new Error("Zu viele Treffer. Bitte weniger Kategorien auswählen.");
|
||||
};
|
||||
@@ -175,7 +175,7 @@ async function prepare(root: string, files: ProjectFile[], rules: ProjectRule[],
|
||||
source: "Datei- oder Ordnername", kind: "path" as const,
|
||||
context: path.value,
|
||||
}));
|
||||
path.hits = withoutWhitelistedHits(withoutPlaceholderHits(found), whitelist);
|
||||
path.hits = withoutWhitelistedHits(withoutPlaceholderHits(found, previousPlaceholders), whitelist);
|
||||
hits.push(...path.hits);
|
||||
if (hits.length > MAX_REVIEW_HITS) throw new Error("Zu viele Treffer. Bitte weniger Kategorien auswählen.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user