MCPcopy
hub / github.com/webpack/webpack / _getFileTimestampAndHash

Method _getFileTimestampAndHash

lib/FileSystemInfo.js:3713–3759  ·  lib/FileSystemInfo.js::FileSystemInfo._getFileTimestampAndHash

* Get file timestamp and hash. * @private * @param {string} path path * @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash | string) => void} callback callback

(path, callback)

Source from the content-addressed store, hash-verified

3711 * @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash | string) => void} callback callback
3712 */
3713 _getFileTimestampAndHash(path, callback) {
3714 /**
3715 * Continue with hash.
3716 * @param {string} hash hash
3717 * @returns {void}
3718 */
3719 const continueWithHash = (hash) => {
3720 const cache = this._fileTimestamps.get(path);
3721 if (cache !== undefined) {
3722 if (cache !== class="st">"ignore") {
3723 /** @type {TimestampAndHash} */
3724 const result = {
3725 .../** @type {FileSystemInfoEntry} */ (cache),
3726 hash
3727 };
3728 this._fileTshs.set(path, result);
3729 return callback(null, result);
3730 }
3731 this._fileTshs.set(path, hash);
3732 return callback(null, hash);
3733 }
3734 this.fileTimestampQueue.add(path, (err, entry) => {
3735 if (err) {
3736 return callback(err);
3737 }
3738 /** @type {TimestampAndHash} */
3739 const result = {
3740 .../** @type {FileSystemInfoEntry} */ (entry),
3741 hash
3742 };
3743 this._fileTshs.set(path, result);
3744 return callback(null, result);
3745 });
3746 };
3747
3748 const cache = this._fileHashes.get(path);
3749 if (cache !== undefined) {
3750 continueWithHash(/** @type {string} */ (cache));
3751 } else {
3752 this.fileHashQueue.add(path, (err, entry) => {
3753 if (err) {
3754 return callback(err);
3755 }
3756 continueWithHash(/** @type {string} */ (entry));
3757 });
3758 }
3759 }
3760
3761 /**
3762 * Processes the provided object.

Callers 2

processCapturedFilesMethod · 0.95

Calls 3

callbackFunction · 0.50
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected