Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Downloader] Stop messing with distutils's internals just to copy directory #3364

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions redbot/cogs/downloader/installable.py
@@ -1,7 +1,7 @@
from __future__ import annotations

import json
import distutils.dir_util
import functools
import shutil
from enum import IntEnum
from pathlib import Path
Expand Down Expand Up @@ -127,15 +127,13 @@ async def copy_to(self, target_dir: Path) -> bool:
if self._location.is_file():
copy_func = shutil.copy2
else:
# clear copy_tree's cache to make sure missing directories are created (GH-2690)
distutils.dir_util._path_created = {}
copy_func = distutils.dir_util.copy_tree
copy_func = functools.partial(shutil.copytree, dirs_exist_ok=True)

# noinspection PyBroadException
try:
copy_func(src=str(self._location), dst=str(target_dir / self._location.stem))
except: # noqa: E722
log.exception("Error occurred when copying path: {}".format(self._location))
log.exception("Error occurred when copying path: %s", self._location)
return False
return True

Expand Down