async function assertNoSymlinkParents(filePath: string): Promise<void> { const resolvedDir = path.resolve(path.dirname(filePath)); const parsed = path.parse(resolvedDir); const relativeParts = path.relative(parsed.root, resolvedDir).split(path.sep).filter(Boolean);
let current = parsed.root; for (const part of relativeParts) {
current = path.join(current, part); const stat = await fs.lstat(current); if (stat.isSymbolicLink()) { if (path.dirname(current) === parsed.root) { continue;
} thrownew Error(`Refusing to write queued log under symlinked directory: ${current}`);
} if (!stat.isDirectory()) { thrownew Error(`Refusing to write queued log under non-directory: ${current}`);
}
}
}
function verifyStableOpenedFile(params: {
preOpenStat?: nodeFs.Stats;
postOpenStat: nodeFs.Stats;
filePath: string;
}): void { if (!params.postOpenStat.isFile()) { thrownew Error(`Refusing to write queued log to non-file: ${params.filePath}`);
} if (params.postOpenStat.nlink > 1) { thrownew Error(`Refusing to write queued log to hardlinked file: ${params.filePath}`);
} const pre = params.preOpenStat; if (pre && (pre.dev !== params.postOpenStat.dev || pre.ino !== params.postOpenStat.ino)) { thrownew Error(`Refusing to write queued log after file changed: ${params.filePath}`);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.