From 760059f8f0c6ac0f73fe1a1e1c8ec13ab28539da Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 31 Jan 2024 14:37:51 -0500 Subject: [PATCH] fix(backup): fixed some stuff --- backup/backup.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/backup/backup.py b/backup/backup.py index a21f285..add16f6 100644 --- a/backup/backup.py +++ b/backup/backup.py @@ -144,11 +144,16 @@ class Backup(commands.Cog): continue else: - cog_names = [] + cog_modules = [] for cog in cogs: - cog_names.append(cog['name']) + try: + cog_module = InstalledCog.convert(ctx, cog['name']) + except commands.BadArgument: + uninstall_e.append(f"Failed to uninstall {cog['name']}") + continue + cog_modules.append(cog_module) - for cog in set(cog_names): + for cog in set(cog.name for cog in cog_modules): poss_installed_path = (await downloader.cog_install_path()) / cog if poss_installed_path.exists(): with contextlib.suppress(commands.ExtensionNotLoaded): @@ -157,7 +162,7 @@ class Backup(commands.Cog): await downloader._delete_cog(poss_installed_path) else: uninstall_e.append(f"Failed to uninstall {cog}") - await downloader._remove_from_installed(cog) + await downloader._remove_from_installed(cog_modules) for cog in cogs: cog_name = cog['name'] @@ -168,16 +173,16 @@ class Backup(commands.Cog): commit = None async with repository.checkout(commit, exit_to_rev=repo.branch): - cogs, message = await downloader._filter_incorrect_cogs_by_names(repository, [cog_name]) # pylint: disable=protected-access + cogs_c, message = await downloader._filter_incorrect_cogs_by_names(repository, [cog_name]) # pylint: disable=protected-access if not cogs: install_e.append(message) continue - failed_reqs = await downloader._install_requirements(cogs) + failed_reqs = await downloader._install_requirements(cogs_c) if failed_reqs: install_e.append(f"Failed to install {cog_name} due to missing requirements: {failed_reqs}") continue - installed_cogs, failed_cogs = await downloader._install_cogs(cogs) + installed_cogs, failed_cogs = await downloader._install_cogs(cogs_c) if repo.available_libraries: installed_libs, failed_libs = await repository.install_libraries(target_dir=downloader.SHAREDLIB_PATH, req_target_dir=downloader.LIB_PATH)