









@@ -246,6 +246,14 @@ function listCacheFiles(rootDir, entries, fsImpl) {
246246.toSorted();
247247}
248248249+function portableRelativePath(rootDir, filePath) {
250+return path.relative(rootDir, filePath).split(path.sep).join("/");
251+}
252+253+function normalizePortablePath(filePath) {
254+return filePath.replaceAll("\\", "/");
255+}
256+249257function resolveCachePaths(rootDir, step) {
250258const safeLabel = step.label.replace(/[^a-zA-Z0-9._-]+/g, "_");
251259const cacheDir = path.resolve(rootDir, ".artifacts/build-all-cache", safeLabel);
@@ -260,7 +268,7 @@ function hashInputFiles(rootDir, files, fsImpl) {
260268const hash = createHash("sha256");
261269hash.update(`v${BUILD_CACHE_VERSION}\0`);
262270for (const file of files) {
263-hash.update(path.relative(rootDir, file));
271+hash.update(portableRelativePath(rootDir, file));
264272hash.update("\0");
265273hash.update(fsImpl.readFileSync(file));
266274hash.update("\0");
@@ -305,8 +313,10 @@ export function resolveBuildAllStepCacheState(step, params = {}) {
305313const { outputRoot, stampPath } = resolveCachePaths(rootDir, step);
306314const stamp = readCacheStamp(stampPath, fsImpl);
307315const outputFiles = listCacheFiles(rootDir, step.cache.outputs, fsImpl);
308-const relativeOutputFiles = outputFiles.map((file) => path.relative(rootDir, file));
309-const stampedOutputs = Array.isArray(stamp?.outputs) ? stamp.outputs : [];
316+const relativeOutputFiles = outputFiles.map((file) => portableRelativePath(rootDir, file));
317+const stampedOutputs = Array.isArray(stamp?.outputs)
318+ ? stamp.outputs.map((entry) => normalizePortablePath(entry))
319+ : [];
310320const stampMatches = stamp?.version === BUILD_CACHE_VERSION && stamp.signature === signature;
311321const actualOutputsPresent =
312322stampedOutputs.length > 0 && hasAllFiles(rootDir, stampedOutputs, fsImpl);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。