fix lost file timestamps due to snapshot deduplication

fix missing startTime in deduped snapshots
This commit is contained in:
Tobias Koppers 2020-05-30 21:09:53 +02:00
parent 255ae13f59
commit beb58fd23d
1 changed files with 22 additions and 4 deletions

View File

@ -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) {