rename missingTimestamps to missingExistance and only store booleans
This commit is contained in:
parent
1e5f3d4a8f
commit
c124637646
|
@ -50,7 +50,7 @@ const INVALID = Symbol("invalid");
|
|||
* @property {Map<string, string | "error">=} fileHashes
|
||||
* @property {Map<string, FileSystemInfoEntry | "ignore" | "error">=} contextTimestamps
|
||||
* @property {Map<string, string | "error">=} contextHashes
|
||||
* @property {Map<string, FileSystemInfoEntry | "ignore" | "error">=} missingTimestamps
|
||||
* @property {Map<string, boolean | "ignore" | "error">=} missingExistance
|
||||
* @property {Map<string, string | "error">=} managedItemInfo
|
||||
*/
|
||||
|
||||
|
@ -178,6 +178,15 @@ const getManagedItem = (managedPath, path) => {
|
|||
return path.slice(0, i);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {FileSystemInfoEntry | "ignore"} entry file system info entry
|
||||
* @returns {boolean | "ignore"} existance flag
|
||||
*/
|
||||
const toExistance = entry => {
|
||||
if (entry === "ignore") return entry;
|
||||
return Boolean(entry);
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to access information about the filesystem in a cached way
|
||||
*/
|
||||
|
@ -656,6 +665,7 @@ class FileSystemInfo {
|
|||
* @param {Iterable<string>} directories all directories
|
||||
* @param {Iterable<string>} missing all missing files or directories
|
||||
* @param {Object} options options object (for future extensions)
|
||||
* @param {boolean=} options.hash should use hash to snapshot
|
||||
* @param {function(WebpackError=, Snapshot=): void} callback callback function
|
||||
* @returns {void}
|
||||
*/
|
||||
|
@ -668,8 +678,8 @@ class FileSystemInfo {
|
|||
const contextTimestamps = new Map();
|
||||
/** @type {Map<string, string | "error">} */
|
||||
const contextHashes = new Map();
|
||||
/** @type {Map<string, FileSystemInfoEntry | "ignore" | "error">} */
|
||||
const missingTimestamps = new Map();
|
||||
/** @type {Map<string, boolean | "ignore" | "error">} */
|
||||
const missingExistance = new Map();
|
||||
/** @type {Map<string, string | "error">} */
|
||||
const managedItemInfo = new Map();
|
||||
|
||||
|
@ -685,8 +695,8 @@ class FileSystemInfo {
|
|||
if (contextTimestamps.size !== 0)
|
||||
snapshot.contextTimestamps = contextTimestamps;
|
||||
if (contextHashes.size !== 0) snapshot.contextHashes = contextHashes;
|
||||
if (missingTimestamps.size !== 0)
|
||||
snapshot.missingTimestamps = missingTimestamps;
|
||||
if (missingExistance.size !== 0)
|
||||
snapshot.missingExistance = missingExistance;
|
||||
if (managedItemInfo.size !== 0)
|
||||
snapshot.managedItemInfo = managedItemInfo;
|
||||
this._snapshotCache.set(snapshot, true);
|
||||
|
@ -861,7 +871,7 @@ class FileSystemInfo {
|
|||
}
|
||||
const cache = this._fileTimestamps.get(path);
|
||||
if (cache !== undefined) {
|
||||
missingTimestamps.set(path, cache);
|
||||
missingExistance.set(path, toExistance(cache));
|
||||
} else {
|
||||
jobs++;
|
||||
this.fileTimestampQueue.add(path, (err, entry) => {
|
||||
|
@ -871,9 +881,9 @@ class FileSystemInfo {
|
|||
`Error snapshotting missing timestamp of ${path}: ${err}`
|
||||
);
|
||||
}
|
||||
missingTimestamps.set(path, "error");
|
||||
missingExistance.set(path, "error");
|
||||
} else {
|
||||
missingTimestamps.set(path, entry);
|
||||
missingExistance.set(path, toExistance(entry));
|
||||
}
|
||||
jobDone();
|
||||
});
|
||||
|
@ -940,10 +950,10 @@ class FileSystemInfo {
|
|||
snapshot2.contextHashes
|
||||
);
|
||||
}
|
||||
if (snapshot1.missingTimestamps || snapshot2.missingTimestamps) {
|
||||
snapshot.missingTimestamps = mergeMaps(
|
||||
snapshot1.missingTimestamps,
|
||||
snapshot2.missingTimestamps
|
||||
if (snapshot1.missingExistance || snapshot2.missingExistance) {
|
||||
snapshot.missingExistance = mergeMaps(
|
||||
snapshot1.missingExistance,
|
||||
snapshot2.missingExistance
|
||||
);
|
||||
}
|
||||
if (snapshot1.managedItemInfo || snapshot2.managedItemInfo) {
|
||||
|
@ -983,7 +993,7 @@ class FileSystemInfo {
|
|||
fileHashes,
|
||||
contextTimestamps,
|
||||
contextHashes,
|
||||
missingTimestamps,
|
||||
missingExistance,
|
||||
managedItemInfo
|
||||
} = snapshot;
|
||||
let jobs = 1;
|
||||
|
@ -1033,8 +1043,8 @@ class FileSystemInfo {
|
|||
};
|
||||
/**
|
||||
* @param {string} path file path
|
||||
* @param {FileSystemInfoEntry | "ignore"} current current entry
|
||||
* @param {FileSystemInfoEntry | "ignore" | "error"} snap entry from snapshot
|
||||
* @param {boolean | "ignore"} current current entry
|
||||
* @param {boolean | "ignore" | "error"} snap entry from snapshot
|
||||
* @returns {boolean} true, if ok
|
||||
*/
|
||||
const checkExistance = (path, current, snap) => {
|
||||
|
@ -1220,11 +1230,11 @@ class FileSystemInfo {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (missingTimestamps) {
|
||||
for (const [path, ts] of missingTimestamps) {
|
||||
if (missingExistance) {
|
||||
for (const [path, existance] of missingExistance) {
|
||||
const cache = this._fileTimestamps.get(path);
|
||||
if (cache !== undefined) {
|
||||
if (!checkExistance(path, cache, ts)) {
|
||||
if (!checkExistance(path, toExistance(cache), existance)) {
|
||||
invalid();
|
||||
return;
|
||||
}
|
||||
|
@ -1232,7 +1242,7 @@ class FileSystemInfo {
|
|||
jobs++;
|
||||
this.fileTimestampQueue.add(path, (err, entry) => {
|
||||
if (err) return invalidWithError(path, err);
|
||||
if (!checkExistance(path, entry, ts)) {
|
||||
if (!checkExistance(path, toExistance(entry), existance)) {
|
||||
invalid();
|
||||
} else {
|
||||
jobDone();
|
||||
|
|
Loading…
Reference in New Issue