Fix path handling

This commit is contained in:
Benjamin Bädorf 2023-01-25 23:40:57 +01:00
parent 5577aaa159
commit 699364de3e
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C

View file

@ -19,7 +19,7 @@ import { join } from "https://deno.land/std@0.173.0/path/mod.ts";
p.close(); p.close();
const outputStr = (new TextDecoder()).decode(output); const outputStr = (new TextDecoder()).decode(output);
const fileNames = [...new Set(outputStr.split('\n').filter(s => !!s))].map(s => join(backupDir, s)); const fileNames = [...new Set(outputStr.split('\n').filter(s => !!s))];
const totalFiles = fileNames.length; const totalFiles = fileNames.length;
let filesSuccess = 0; let filesSuccess = 0;
@ -28,13 +28,14 @@ import { join } from "https://deno.land/std@0.173.0/path/mod.ts";
for (let i = 0; i < totalFiles; i += BATCH_SIZE) { for (let i = 0; i < totalFiles; i += BATCH_SIZE) {
fileData = [ fileData = [
...fileData, ...fileData,
...(await Promise.all(fileNames.slice(i, i + BATCH_SIZE).map(async (conflictedFileName) => { ...(await Promise.all(fileNames.slice(i, i + BATCH_SIZE).map(async (relativeConflictedFileName) => {
const conflictedFileName = join(backupDir, relativeConflictedFileName);
const conflictedNameMatch = conflictedFileName.match(CONFLICTED_COPY_REGEX); const conflictedNameMatch = conflictedFileName.match(CONFLICTED_COPY_REGEX);
if (!conflictedNameMatch) { if (!conflictedNameMatch) {
return `[${conflictedFileName}] encountered regex error`; return `[${conflictedFileName}] encountered regex error`;
} }
const conflictString = conflictedNameMatch[1]; const conflictString = conflictedNameMatch[1];
const nonConflictedFileName = join(mainDir, conflictedFileName.replace(conflictString, '')); const nonConflictedFileName = join(mainDir, relativeConflictedFileName.replace(conflictString, ''));
const conflictedFile = await Deno.open(conflictedFileName, { read: true }); const conflictedFile = await Deno.open(conflictedFileName, { read: true });
const conflictedFileInfo = await Deno.fstat(conflictedFile.rid); const conflictedFileInfo = await Deno.fstat(conflictedFile.rid);