forked from r.muellner/velum-raycast
fix: release mappings from edited in-place project files
This commit is contained in:
@@ -618,7 +618,8 @@ async function assertNoSymlinkParents(root: string, relPath: string): Promise<vo
|
||||
}
|
||||
|
||||
/** Replaces selected originals only after every output exists and a private backup is complete. */
|
||||
export async function replaceProjectFilesInPlace(projectPath: string, runDirectory: string, files: RunFile[]): Promise<void> {
|
||||
export async function replaceProjectFilesInPlace(projectPath: string, runDirectory: string, files: RunFile[],
|
||||
expectedHashes?: ReadonlyMap<string, string>): Promise<void> {
|
||||
const root = resolve(projectPath);
|
||||
const sourcePaths = new Set(files.map((file) => resolveWithin(root, file.source)));
|
||||
const targetPaths = new Set<string>();
|
||||
@@ -651,7 +652,13 @@ export async function replaceProjectFilesInPlace(projectPath: string, runDirecto
|
||||
|
||||
const written: string[] = [];
|
||||
try {
|
||||
for (const file of files) await fs.unlink(resolveWithin(root, file.source));
|
||||
for (const file of files) {
|
||||
const source = resolveWithin(root, file.source);
|
||||
if (expectedHashes && digest(await fs.readFile(source)) !== expectedHashes.get(file.source)) {
|
||||
throw new Error(`Projektdatei wurde vor dem Ersetzen erneut geändert: ${file.source}`);
|
||||
}
|
||||
await fs.unlink(source);
|
||||
}
|
||||
for (const file of files) {
|
||||
const target = resolveWithin(root, file.output);
|
||||
await fs.mkdir(dirname(target), { recursive: true, mode: 0o700 });
|
||||
|
||||
Reference in New Issue
Block a user