Skip to content

Privacy plugin fails to copy file if unable to download #8076

@Xenira

Description

@Xenira

Context

No response

Bug description

If the privacy plugin cant download an external image the build process fails while trying to copy that file.

INFO    -  Downloading external file: https://squidfunk.github.io/mkdocs-material/assets/images/layers/3-astronaut-10.png
WARNING -  Couldn't retrieve https://squidfunk.github.io/mkdocs-material/assets/images/layers/3-astronaut-10.png: 404 Client Error: Not Found for url:
           https://squidfunk.github.io/mkdocs-material/assets/images/layers/3-astronaut-10.png
Traceback (most recent call last):
  File "/home/<redacted>/mkdocmatrep/venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/mkdocs/__main__.py", line 288, in build_command
    build.build(cfg, dirty=not clean)
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/mkdocs/commands/build.py", line 347, in build
    config.plugins.on_post_build(config=config)
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/mkdocs/plugins.py", line 602, in on_post_build
    return self.run_event('post_build', config=config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/mkdocs/plugins.py", line 568, in run_event
    result = method(**kwargs)
             ^^^^^^^^^^^^^^^^
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/material/plugins/privacy/plugin.py", line 205, in on_post_build
    file.copy_file()
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/mkdocs/structure/files.py", line 485, in copy_file
    utils.copy_file(self.abs_src_path, output_path)
  File "/home/<redacted>/mkdocmatrep/venv/lib/python3.12/site-packages/mkdocs/utils/__init__.py", line 123, in copy_file
    shutil.copyfile(source_path, output_path)
  File "/run/current-system/sw/lib/python3.12/shutil.py", line 260, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/<redacted>/mkdocmatrep/.cache/plugin/privacy/assets/external/squidfunk.github.io/mkdocs-material/assets/images/layers/3-astronaut-10.png'

Related links

Reproduction

9.6.7-privacy-image-missing.zip

Steps to reproduce

  1. Activate privacy plugin
  2. Have an external image that cant be downloaded
  3. Try to build

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions