MCPcopy
hub / github.com/webpack/webpack / checkContext

Method checkContext

lib/FileSystemInfo.js:3204–3241  ·  view source on GitHub ↗
(path, c, s, log = true)

Source from the content-addressed store, hash-verified

3202 * @returns {boolean} true, if ok
3203 */
3204 const checkContext = (path, c, s, log = true) => {
3205 if (c === s) return true;
3206 if (!checkExistence(path, Boolean(c), Boolean(s))) return false;
3207 if (c) {
3208 // For existing items only
3209 if (typeof startTime === "number" && c.safeTime > startTime) {
3210 // If a change happened after starting reading the item
3211 // this may no longer be valid
3212 if (log && this._remainingLogs > 0) {
3213 this._log(
3214 path,
3215 "it may have changed (%d) after the start time of the snapshot (%d)",
3216 c.safeTime,
3217 startTime
3218 );
3219 }
3220 return false;
3221 }
3222 const snap = /** @type {ResolvedContextFileSystemInfoEntry} */ (s);
3223 if (
3224 snap.timestampHash !== undefined &&
3225 c.timestampHash !== snap.timestampHash
3226 ) {
3227 // If we have a timestampHash (it was a directory) and it differs from current timestampHash
3228 // it's invalid
3229 if (log && this._remainingLogs > 0) {
3230 this._log(
3231 path,
3232 "timestamps hashes differ (%s != %s)",
3233 c.timestampHash,
3234 snap.timestampHash
3235 );
3236 }
3237 return false;
3238 }
3239 }
3240 return true;
3241 };
3242 if (snapshot.hasChildren()) {
3243 /**
3244 * Processes the provided err.

Callers

nothing calls this directly

Calls 1

_logMethod · 0.95

Tested by

no test coverage detected