MCPcopy
hub / github.com/webpack/webpack / _openPack

Method _openPack

lib/cache/PackFileCacheStrategy.js:1227–1388  ·  lib/cache/PackFileCacheStrategy.js::PackFileCacheStrategy._openPack

* Returns the pack. * @returns {Promise<Pack>} the pack

()

Source from the content-addressed store, hash-verified

1225 * @returns {Promise<Pack>} the pack
1226 */
1227 _openPack() {
1228 const { logger, profile, cacheLocation, version } = this;
1229 /** @type {Snapshot} */
1230 let buildSnapshot;
1231 /** @type {BuildDependencies} */
1232 let buildDependencies;
1233 /** @type {BuildDependencies} */
1234 let newBuildDependencies;
1235 /** @type {Snapshot} */
1236 let resolveBuildDependenciesSnapshot;
1237 /** @type {ResolveResults | undefined} */
1238 let resolveResults;
1239 logger.time(class="st">"restore cache container");
1240 return this.fileSerializer
1241 .deserialize(null, {
1242 filename: `${cacheLocation}/index${this._extension}`,
1243 extension: `${this._extension}`,
1244 logger,
1245 profile,
1246 retainedBuffer: this.allowCollectingMemory
1247 ? allowCollectingMemory
1248 : undefined
1249 })
1250 .catch((err) => {
1251 if (err.code !== class="st">"ENOENT") {
1252 logger.warn(
1253 `Restoring pack failed from ${cacheLocation}${this._extension}: ${err}`
1254 );
1255 logger.debug(err.stack);
1256 } else {
1257 logger.debug(
1258 `No pack exists at ${cacheLocation}${this._extension}: ${err}`
1259 );
1260 }
1261 return undefined;
1262 })
1263 .then((packContainer) => {
1264 logger.timeEnd(class="st">"restore cache container");
1265 if (!packContainer) return;
1266 if (!(packContainer instanceof PackContainer)) {
1267 logger.warn(
1268 `Restored pack from ${cacheLocation}${this._extension}, but contained content is unexpected.`,
1269 packContainer
1270 );
1271 return;
1272 }
1273 if (packContainer.version !== version) {
1274 logger.log(
1275 `Restored pack from ${cacheLocation}${this._extension}, but version doesn't match.`
1276 );
1277 return;
1278 }
1279 logger.time(class="st">"check build dependencies");
1280 return Promise.all([
1281 new Promise((resolve, _reject) => {
1282 this.fileSystemInfo.checkSnapshotValid(
1283 packContainer.buildSnapshot,
1284 (err, valid) => {

Callers 2

constructorMethod · 0.95
_getPackMethod · 0.95

Calls 10

resolveFunction · 0.85
timeMethod · 0.80
warnMethod · 0.80
debugMethod · 0.80
timeEndMethod · 0.80
logMethod · 0.80
checkSnapshotValidMethod · 0.80
deserializeMethod · 0.45
addAllMethod · 0.45

Tested by

no test coverage detected