From beb58fd23dbeb87a7ca0ca257a4ee228457cef4e Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 30 May 2020 21:09:53 +0200 Subject: [PATCH] fix lost file timestamps due to snapshot deduplication fix missing startTime in deduped snapshots --- lib/FileSystemInfo.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/FileSystemInfo.js b/lib/FileSystemInfo.js index a5987690e..2899a6386 100644 --- a/lib/FileSystemInfo.js +++ b/lib/FileSystemInfo.js @@ -835,6 +835,13 @@ class FileSystemInfo { if (optimizationEntry.shared > 0) { // It's a shared snapshot // We can't change it, so we can only use it when all files match + // and startTime is compatible + if ( + startTime && + (!snapshot.startTime || snapshot.startTime > startTime) + ) { + continue; + } const nonSharedFiles = new Set(); for (const path of optimizationEntry.snapshotContent) { if (!capturedFiles.has(path)) { @@ -864,7 +871,13 @@ class FileSystemInfo { } // Create and attach snapshot /** @type {Snapshot} */ - const commonSnapshot = { fileTimestamps: commonMap }; + const commonSnapshot = { + startTime: + startTime && snapshot.startTime + ? Math.min(startTime, snapshot.startTime) + : startTime || snapshot.startTime, + fileTimestamps: commonMap + }; children.add(commonSnapshot); if (!snapshot.children) snapshot.children = new Set(); snapshot.children.add(commonSnapshot); @@ -889,7 +902,6 @@ class FileSystemInfo { const ts = snapshot.fileTimestamps.get(path); if (ts === undefined) continue; commonMap.set(path, ts); - snapshot.fileTimestamps.delete(path); } if (commonMap.size < 2) { // Common part it too small @@ -897,7 +909,13 @@ class FileSystemInfo { } // Create and attach snapshot /** @type {Snapshot} */ - const commonSnapshot = { fileTimestamps: commonMap }; + const commonSnapshot = { + startTime: + startTime && snapshot.startTime + ? Math.min(startTime, snapshot.startTime) + : startTime || snapshot.startTime, + fileTimestamps: commonMap + }; children.add(commonSnapshot); if (!snapshot.children) snapshot.children = new Set(); snapshot.children.add(commonSnapshot); @@ -1243,7 +1261,7 @@ class FileSystemInfo { } if (current) { // For existing items only - if (current.safeTime > startTime) { + if (typeof startTime === "number" && current.safeTime > startTime) { // If a change happened after starting reading the item // this may no longer be valid if (this._remainingLogs > 0) {