MCPcopy
hub / github.com/webpack/webpack / createSnapshot

Method createSnapshot

lib/FileSystemInfo.js:2462–2966  ·  lib/FileSystemInfo.js::FileSystemInfo.createSnapshot

* Creates a snapshot. * @param {number | null | undefined} startTime when processing the files has started * @param {Iterable<string> | null | undefined} files all files * @param {Iterable<string> | null | undefined} directories all directories * @param {Iterable<string> | null | undefined}

(startTime, files, directories, missing, options, callback)

Source from the content-addressed store, hash-verified

2460 * @returns {void}
2461 */
2462 createSnapshot(startTime, files, directories, missing, options, callback) {
2463 /** @type {FileTimestamps} */
2464 const fileTimestamps = new Map();
2465 /** @type {FileHashes} */
2466 const fileHashes = new Map();
2467 /** @type {FileTshs} */
2468 const fileTshs = new Map();
2469 /** @type {ContextTimestamps} */
2470 const contextTimestamps = new Map();
2471 /** @type {ContextHashes} */
2472 const contextHashes = new Map();
2473 /** @type {ContextTshs} */
2474 const contextTshs = new Map();
2475 /** @type {MissingExistence} */
2476 const missingExistence = new Map();
2477 /** @type {ManagedItemInfo} */
2478 const managedItemInfo = new Map();
2479 /** @type {ManagedFiles} */
2480 const managedFiles = new Set();
2481 /** @type {ManagedContexts} */
2482 const managedContexts = new Set();
2483 /** @type {ManagedMissing} */
2484 const managedMissing = new Set();
2485 /** @type {Children} */
2486 const children = new Set();
2487
2488 const snapshot = new Snapshot();
2489 if (startTime) snapshot.setStartTime(startTime);
2490
2491 /** @type {Set<string>} */
2492 const managedItems = new Set();
2493
2494 /** 1 = timestamp, 2 = hash, 3 = timestamp + hash */
2495 const mode = options && options.hash ? (options.timestamp ? 3 : 2) : 1;
2496
2497 let jobs = 1;
2498 const jobDone = () => {
2499 if (--jobs === 0) {
2500 if (fileTimestamps.size !== 0) {
2501 snapshot.setFileTimestamps(fileTimestamps);
2502 }
2503 if (fileHashes.size !== 0) {
2504 snapshot.setFileHashes(fileHashes);
2505 }
2506 if (fileTshs.size !== 0) {
2507 snapshot.setFileTshs(fileTshs);
2508 }
2509 if (contextTimestamps.size !== 0) {
2510 snapshot.setContextTimestamps(contextTimestamps);
2511 }
2512 if (contextHashes.size !== 0) {
2513 snapshot.setContextHashes(contextHashes);
2514 }
2515 if (contextTshs.size !== 0) {
2516 snapshot.setContextTshs(contextTshs);
2517 }
2518 if (missingExistence.size !== 0) {
2519 snapshot.setMissingExistence(missingExistence);

Callers 13

_loadEnvMethod · 0.95
buildMethod · 0.80
handleBuildDoneMethod · 0.80
afterAllStoredMethod · 0.80
doRealResolveMethod · 0.80
readLockfileMethod · 0.80
createSnapshotFunction · 0.80
getSnapshotFunction · 0.80
buildFsInfoWithSnapshotFunction · 0.80
buildWithStatsFunction · 0.80
makeFunction · 0.80

Calls 8

setStartTimeMethod · 0.95
joinFunction · 0.85
optimizeMethod · 0.80
debugMethod · 0.80
processFunction · 0.50
getMethod · 0.45
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected