MCPcopy
hub / github.com/webpack/webpack / checkSimilarFile

Method checkSimilarFile

lib/Compiler.js:827–863  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

825 let similarEntry;
826
827 const checkSimilarFile = () => {
828 const caseInsensitiveTargetPath = targetPath.toLowerCase();
829 similarEntry = caseInsensitiveMap.get(caseInsensitiveTargetPath);
830 if (similarEntry !== undefined) {
831 const { path: other, source: otherSource } = similarEntry;
832 if (isSourceEqual(otherSource, source)) {
833 // Size may or may not be available at this point.
834 // If it's not available add to "waiting" list and it will be updated once available
835 if (similarEntry.size !== undefined) {
836 updateWithReplacementSource(similarEntry.size);
837 } else {
838 if (!similarEntry.waiting) similarEntry.waiting = [];
839 similarEntry.waiting.push({ file, cacheEntry });
840 }
841 alreadyWritten();
842 } else {
843 const err =
844 new WebpackError(`Prevent writing to file that only differs in casing or query string from already written file.
845This will lead to a race-condition and corrupted files on case-insensitive file systems.
846${targetPath}
847${other}`);
848 err.file = file;
849 callback(err);
850 }
851 return true;
852 }
853 caseInsensitiveMap.set(
854 caseInsensitiveTargetPath,
855 (similarEntry = /** @type {SimilarEntry} */ ({
856 path: targetPath,
857 source,
858 size: undefined,
859 waiting: undefined
860 }))
861 );
862 return false;
863 };
864
865 /**
866 * get the binary (Buffer) content from the Source

Callers

nothing calls this directly

Calls 5

isSourceEqualFunction · 0.85
callbackFunction · 0.50
getMethod · 0.45
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected