Skip to content

Replacing directory with a regular file breaks squashing #253

@Nixxx11

Description

@Nixxx11
FROM busybox:1.36.1
RUN mkdir /tmp/dir
RUN touch /tmp/dir/file
RUN rm -rf /tmp/dir ; touch /tmp/dir

Squashing this image will produce a broken image containing both /tmp/dir/file and /tmp/dir (second one is a regular file, not a directory). This problem was solved earlier for symlinks (#120 ?), but it is exactly the same for all other types of files

And here is a similar scenario for marker files:

FROM busybox:1.36.1
RUN mkdir /tmp/dir
RUN touch /tmp/dir/file
RUN rm /tmp/dir/file
RUN rm -rf /tmp/dir ; touch /tmp/dir

Here we will have both /tmp/dir/.wh.file and /tmp/dir. I guess this situation is similar to #122

The correct solution would be something like this:

  1. Memorize all files we already added
  2. Memorize all directories we already added
  3. When adding a new file, check whether parent directory already exists or not; if it does and it is not actually a directory, skip the file; otherwise, add the file as normal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions