MCPcopy
hub / github.com/webpack/webpack / _readFileTimestamp

Method _readFileTimestamp

lib/FileSystemInfo.js:3635–3669  ·  view source on GitHub ↗

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

(path, callback)

Source from the content-addressed store, hash-verified

3633 * @type {Processor<string, FileSystemInfoEntry>}
3634 */
3635 _readFileTimestamp(path, callback) {
3636 this.fs.stat(path, (err, _stat) => {
3637 if (err) {
3638 if (err.code === "ENOENT") {
3639 this._fileTimestamps.set(path, null);
3640 this._cachedDeprecatedFileTimestamps = undefined;
3641 return callback(null, null);
3642 }
3643 return callback(/** @type {WebpackError} */ (err));
3644 }
3645 const stat = /** @type {IStats} */ (_stat);
3646 /** @type {FileSystemInfoEntry} */
3647 let ts;
3648 if (stat.isDirectory()) {
3649 ts = {
3650 safeTime: 0,
3651 timestamp: undefined
3652 };
3653 } else {
3654 const mtime = Number(stat.mtime);
3655
3656 if (mtime) applyMtime(mtime);
3657
3658 ts = {
3659 safeTime: mtime ? mtime + FS_ACCURACY : Infinity,
3660 timestamp: mtime
3661 };
3662 }
3663
3664 this._fileTimestamps.set(path, ts);
3665 this._cachedDeprecatedFileTimestamps = undefined;
3666
3667 callback(null, ts);
3668 });
3669 }
3670
3671 /**
3672 * @private

Callers

nothing calls this directly

Calls 3

applyMtimeFunction · 0.85
callbackFunction · 0.50
setMethod · 0.45

Tested by

no test coverage detected