Skip to content

Commit cb73d68

Browse files
committed
fix: defer opaque whiteout application to older layers only
Opaque whiteouts should not affect files from the same layer — only files from older layers. Collecting opaque dirs in a per-layer set and merging after the inner loop prevents new files in the same layer from being incorrectly excluded.
1 parent a2e2c11 commit cb73d68

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/extractor/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,16 @@ function layersWithLatestFileModifications(
236236

237237
// TODO: This removes the information about the layer name, maybe we would need it in the future?
238238
for (const layer of layers) {
239+
// Collect opaque whiteout dirs from this layer, but don't apply them yet —
240+
// they should only affect older layers, not files in the same layer.
241+
const layerOpaqueDirs: Set<string> = new Set();
242+
239243
// go over extracted files products found in this layer
240244
for (const filename of Object.keys(layer)) {
241245
// if finding a deleted file - trimming to its original file name for excluding it from extractedLayers
242246
// + not adding this file
243247
if (isOpaqueWhiteout(filename)) {
244-
// Opaque whiteout: all files in this directory from older layers should be ignored
245-
opaqueWhiteoutDirs.add(path.dirname(filename));
248+
layerOpaqueDirs.add(path.dirname(filename));
246249
continue;
247250
}
248251
if (isWhitedOutFile(filename)) {
@@ -266,6 +269,11 @@ function layersWithLatestFileModifications(
266269
extractedLayers[filename] = layer[filename];
267270
}
268271
}
272+
273+
// Apply this layer's opaque whiteouts for subsequent (older) layers
274+
for (const dir of layerOpaqueDirs) {
275+
opaqueWhiteoutDirs.add(dir);
276+
}
269277
}
270278
return extractedLayers;
271279
}

0 commit comments

Comments
 (0)