MCPcopy
hub / github.com/webpack/webpack / _readContextTimestamp

Method _readContextTimestamp

lib/FileSystemInfo.js:3878–3994  ·  lib/FileSystemInfo.js::FileSystemInfo._readContextTimestamp

* @private * @type {Processor<string, ContextFileSystemInfoEntry>}

(path, callback)

Source from the content-addressed store, hash-verified

3876 * @type {Processor<string, ContextFileSystemInfoEntry>}
3877 */
3878 _readContextTimestamp(path, callback) {
3879 this._readContext(
3880 {
3881 path,
3882 fromImmutablePath: () =>
3883 /** @type {ContextFileSystemInfoEntry | FileSystemInfoEntry | class="st">"ignore" | null} */
3884 (null),
3885 fromManagedItem: (info) => ({
3886 safeTime: 0,
3887 timestampHash: info
3888 }),
3889 fromSymlink: (file, target, callback) => {
3890 callback(
3891 null,
3892 /** @type {ContextFileSystemInfoEntry} */
3893 ({
3894 timestampHash: target,
3895 symlinks: new Set([target])
3896 })
3897 );
3898 },
3899 fromFile: (file, stat, callback) => {
3900 class="cm">// Prefer the cached value over our new stat to report consistent results
3901 const cache = this._fileTimestamps.get(file);
3902 if (cache !== undefined && !isExistenceOnly(cache)) {
3903 return callback(
3904 null,
3905 cache === class="st">"ignore"
3906 ? null
3907 : /** @type {FileSystemInfoEntry | null} */ (cache)
3908 );
3909 }
3910
3911 const mtime = Number(stat.mtime);
3912
3913 if (mtime) applyMtime(mtime);
3914
3915 /** @type {FileSystemInfoEntry} */
3916 const ts = {
3917 safeTime: mtime ? mtime + FS_ACCURACY : Infinity,
3918 timestamp: mtime
3919 };
3920
3921 this._fileTimestamps.set(file, ts);
3922 this._cachedDeprecatedFileTimestamps = undefined;
3923 callback(null, ts);
3924 },
3925 fromDirectory: (directory, stat, callback) => {
3926 this.contextTimestampQueue.increaseParallelism();
3927 this._getUnresolvedContextTimestamp(directory, (err, tsEntry) => {
3928 this.contextTimestampQueue.decreaseParallelism();
3929 callback(err, tsEntry);
3930 });
3931 },
3932 reduce: (files, tsEntries) => {
3933 /** @type {undefined | Symlinks} */
3934 let symlinks;
3935

Callers

nothing calls this directly

Calls 13

_readContextMethod · 0.95
isExistenceOnlyFunction · 0.85
applyMtimeFunction · 0.85
createHashFunction · 0.85
addAllFunction · 0.85
increaseParallelismMethod · 0.80
decreaseParallelismMethod · 0.80
callbackFunction · 0.50
getMethod · 0.45
setMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected