forked from blizzthewolf/SeaCogs
fix(backup): fixed not installing cogs from repositories that already exist
This commit is contained in:
parent
22237a21b1
commit
49907e7803
1 changed files with 62 additions and 63 deletions
125
backup/backup.py
125
backup/backup.py
|
@ -150,73 +150,72 @@ class Backup(commands.Cog):
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
else:
|
cog_modules = []
|
||||||
cog_modules = []
|
for cog in cogs:
|
||||||
for cog in cogs:
|
try:
|
||||||
try:
|
cog_module = await InstalledCog.convert(ctx, cog['name'])
|
||||||
cog_module = await InstalledCog.convert(ctx, cog['name'])
|
except commands.BadArgument:
|
||||||
except commands.BadArgument:
|
uninstall_e.append(f"Failed to uninstall {cog['name']}")
|
||||||
uninstall_e.append(f"Failed to uninstall {cog['name']}")
|
continue
|
||||||
|
cog_modules.append(cog_module)
|
||||||
|
|
||||||
|
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):
|
||||||
|
await ctx.bot.unload_extension(cog)
|
||||||
|
await ctx.bot.remove_loaded_package(cog)
|
||||||
|
await downloader._delete_cog(poss_installed_path) # pylint: disable=protected-access
|
||||||
|
uninstall_s.append(f"Uninstalled {cog}")
|
||||||
|
else:
|
||||||
|
uninstall_e.append(f"Failed to uninstall {cog}")
|
||||||
|
await downloader._remove_from_installed(cog_modules) # pylint: disable=protected-access
|
||||||
|
|
||||||
|
for cog in cogs:
|
||||||
|
cog_name = cog['name']
|
||||||
|
cog_pinned = cog['pinned']
|
||||||
|
if cog_pinned:
|
||||||
|
commit = cog['commit']
|
||||||
|
else:
|
||||||
|
commit = None
|
||||||
|
|
||||||
|
# If you're forking this cog, make sure to change these strings!
|
||||||
|
if cog_name == 'backup' and 'SeaswimmerTheFsh/SeaCogs' in url:
|
||||||
|
continue
|
||||||
|
|
||||||
|
async with repository.checkout(commit, exit_to_rev=repository.branch):
|
||||||
|
cogs_c, message = await downloader._filter_incorrect_cogs_by_names(repository, [cog_name]) # pylint: disable=protected-access
|
||||||
|
if not cogs_c:
|
||||||
|
install_e.append(message)
|
||||||
|
continue
|
||||||
|
failed_reqs = await downloader._install_requirements(cogs_c) # pylint: disable=protected-access
|
||||||
|
if failed_reqs:
|
||||||
|
install_e.append(f"Failed to install {cog_name} due to missing requirements: {failed_reqs}")
|
||||||
continue
|
continue
|
||||||
cog_modules.append(cog_module)
|
|
||||||
|
|
||||||
for cog in set(cog.name for cog in cog_modules):
|
installed_cogs, failed_cogs = await downloader._install_cogs(cogs_c) # pylint: disable=protected-access
|
||||||
poss_installed_path = (await downloader.cog_install_path()) / cog
|
|
||||||
if poss_installed_path.exists():
|
if repository.available_libraries:
|
||||||
with contextlib.suppress(commands.ExtensionNotLoaded):
|
installed_libs, failed_libs = await repository.install_libraries(target_dir=downloader.SHAREDLIB_PATH, req_target_dir=downloader.LIB_PATH)
|
||||||
await ctx.bot.unload_extension(cog)
|
|
||||||
await ctx.bot.remove_loaded_package(cog)
|
|
||||||
await downloader._delete_cog(poss_installed_path) # pylint: disable=protected-access
|
|
||||||
uninstall_s.append(f"Uninstalled {cog}")
|
|
||||||
else:
|
else:
|
||||||
uninstall_e.append(f"Failed to uninstall {cog}")
|
installed_libs = None
|
||||||
await downloader._remove_from_installed(cog_modules) # pylint: disable=protected-access
|
failed_libs = None
|
||||||
|
|
||||||
for cog in cogs:
|
|
||||||
cog_name = cog['name']
|
|
||||||
cog_pinned = cog['pinned']
|
|
||||||
if cog_pinned:
|
if cog_pinned:
|
||||||
commit = cog['commit']
|
for cog in installed_cogs:
|
||||||
else:
|
cog.pinned = True
|
||||||
commit = None
|
|
||||||
|
|
||||||
# If you're forking this cog, make sure to change these strings!
|
await downloader._save_to_installed(installed_cogs + installed_libs if installed_libs else installed_cogs) # pylint: disable=protected-access
|
||||||
if cog_name == 'backup' and 'SeaswimmerTheFsh/SeaCogs' in url:
|
if installed_cogs:
|
||||||
continue
|
installed_cog_name = installed_cogs[0].name
|
||||||
|
install_s.append(f"Installed {installed_cog_name}")
|
||||||
async with repository.checkout(commit, exit_to_rev=repository.branch):
|
if installed_libs:
|
||||||
cogs_c, message = await downloader._filter_incorrect_cogs_by_names(repository, [cog_name]) # pylint: disable=protected-access
|
for lib in installed_libs:
|
||||||
if not cogs_c:
|
install_s.append(f"Installed {lib.name} required for {cog_name}")
|
||||||
install_e.append(message)
|
if failed_cogs:
|
||||||
continue
|
failed_cog_name = failed_cogs[0].name
|
||||||
failed_reqs = await downloader._install_requirements(cogs_c) # pylint: disable=protected-access
|
install_e.append(f"Failed to install {failed_cog_name}")
|
||||||
if failed_reqs:
|
if failed_libs:
|
||||||
install_e.append(f"Failed to install {cog_name} due to missing requirements: {failed_reqs}")
|
for lib in failed_libs:
|
||||||
continue
|
install_e.append(f"Failed to install {lib.name} required for {cog_name}")
|
||||||
|
|
||||||
installed_cogs, failed_cogs = await downloader._install_cogs(cogs_c) # pylint: disable=protected-access
|
|
||||||
|
|
||||||
if repository.available_libraries:
|
|
||||||
installed_libs, failed_libs = await repository.install_libraries(target_dir=downloader.SHAREDLIB_PATH, req_target_dir=downloader.LIB_PATH)
|
|
||||||
else:
|
|
||||||
installed_libs = None
|
|
||||||
failed_libs = None
|
|
||||||
|
|
||||||
if cog_pinned:
|
|
||||||
for cog in installed_cogs:
|
|
||||||
cog.pinned = True
|
|
||||||
|
|
||||||
await downloader._save_to_installed(installed_cogs + installed_libs if installed_libs else installed_cogs) # pylint: disable=protected-access
|
|
||||||
if installed_cogs:
|
|
||||||
installed_cog_name = installed_cogs[0].name
|
|
||||||
install_s.append(f"Installed {installed_cog_name}")
|
|
||||||
if installed_libs:
|
|
||||||
for lib in installed_libs:
|
|
||||||
install_s.append(f"Installed {lib.name} required for {cog_name}")
|
|
||||||
if failed_cogs:
|
|
||||||
failed_cog_name = failed_cogs[0].name
|
|
||||||
install_e.append(f"Failed to install {failed_cog_name}")
|
|
||||||
if failed_libs:
|
|
||||||
for lib in failed_libs:
|
|
||||||
install_e.append(f"Failed to install {lib.name} required for {cog_name}")
|
|
||||||
await ctx.send("Import complete!", file=text_to_file(f"Repositories:\n{repo_s}\n\nRepository Errors:\n{repo_e}\n\nUninstalled Cogs:\n{uninstall_s}\n\nUninstalled Cogs Errors:\n{uninstall_e}\n\nInstalled Cogs:\n{install_s}\n\nInstalled Cogs Errors:\n{install_e}", 'backup.log'))
|
await ctx.send("Import complete!", file=text_to_file(f"Repositories:\n{repo_s}\n\nRepository Errors:\n{repo_e}\n\nUninstalled Cogs:\n{uninstall_s}\n\nUninstalled Cogs Errors:\n{uninstall_e}\n\nInstalled Cogs:\n{install_s}\n\nInstalled Cogs Errors:\n{install_e}", 'backup.log'))
|
||||||
|
|
Loading…
Reference in a new issue