MCPcopy
hub / github.com/webpack/webpack / _checkSnapshotValidNoCache

Method _checkSnapshotValidNoCache

lib/FileSystemInfo.js:3083–3629  ·  view source on GitHub ↗

* Check snapshot valid no cache. * @private * @param {Snapshot} snapshot the snapshot made * @param {CheckSnapshotValidCallback} callback callback function * @returns {void}

(snapshot, callback)

Source from the content-addressed store, hash-verified

3081 * @returns {void}
3082 */
3083 _checkSnapshotValidNoCache(snapshot, callback) {
3084 /** @type {number | undefined} */
3085 let startTime;
3086 if (snapshot.hasStartTime()) {
3087 startTime = snapshot.startTime;
3088 }
3089 let jobs = 1;
3090 const jobDone = () => {
3091 if (--jobs === 0) {
3092 this._snapshotCache.set(snapshot, true);
3093 callback(null, true);
3094 }
3095 };
3096 const invalid = () => {
3097 if (jobs > 0) {
3098 // large negative number instead of NaN or something else to keep jobs to stay a SMI (v8)
3099 jobs = -100000000;
3100 this._snapshotCache.set(snapshot, false);
3101 callback(null, false);
3102 }
3103 };
3104 /**
3105 * Invalid with error.
3106 * @param {string} path path
3107 * @param {WebpackError} err err
3108 */
3109 const invalidWithError = (path, err) => {
3110 if (this._remainingLogs > 0) {
3111 this._log(path, "error occurred: %s", err);
3112 }
3113 invalid();
3114 };
3115 /**
3116 * Checks true, if ok.
3117 * @param {string} path file path
3118 * @param {string | null} current current hash
3119 * @param {string | null} snap snapshot hash
3120 * @returns {boolean} true, if ok
3121 */
3122 const checkHash = (path, current, snap) => {
3123 if (current !== snap) {
3124 // If hash differ it's invalid
3125 if (this._remainingLogs > 0) {
3126 this._log(path, "hashes differ (%s != %s)", current, snap);
3127 }
3128 return false;
3129 }
3130 return true;
3131 };
3132 /**
3133 * Checks true, if ok.
3134 * @param {string} path file path
3135 * @param {boolean} current current entry
3136 * @param {boolean} snap entry from snapshot
3137 * @returns {boolean} true, if ok
3138 */
3139 const checkExistence = (path, current, snap) => {
3140 if (!current !== !snap) {

Callers 1

checkSnapshotValidMethod · 0.95

Calls 15

getContextTimestampMethod · 0.95
isExistenceOnlyFunction · 0.85
getResolvedTimestampFunction · 0.85
hasStartTimeMethod · 0.80
hasChildrenMethod · 0.80
hasFileTimestampsMethod · 0.80
hasFileHashesMethod · 0.80
hasFileTshsMethod · 0.80
hasContextTimestampsMethod · 0.80
hasContextHashesMethod · 0.80

Tested by

no test coverage detected