[Downloader]: RepoManager: don't load repos in __init__ (#2829)

Loading repos is already done in initialize() method.
This could actually turn out badly
if both
of git processes would touch the same repo at the same time.

This also fixes create_backup in
setup.py - now it properly generates repos.json
This commit is contained in:
jack1142 2019-07-02 03:57:30 +02:00 committed by Toby Harradine
parent 081bf663a4
commit 942dca43d3
2 changed files with 2 additions and 4 deletions

View File

@ -540,9 +540,6 @@ class RepoManager:
def __init__(self): def __init__(self):
self._repos = {} self._repos = {}
loop = asyncio.get_event_loop()
loop.create_task(self._load_repos(set=True)) # str_name: Repo
async def initialize(self): async def initialize(self):
await self._load_repos(set=True) await self._load_repos(set=True)

View File

@ -409,8 +409,9 @@ async def create_backup(instance):
from redbot.cogs.downloader.repo_manager import RepoManager from redbot.cogs.downloader.repo_manager import RepoManager
repo_mgr = RepoManager() repo_mgr = RepoManager()
await repo_mgr.initialize()
repo_output = [] repo_output = []
for _, repo in repo_mgr._repos: for repo in repo_mgr._repos.values():
repo_output.append({"url": repo.url, "name": repo.name, "branch": repo.branch}) repo_output.append({"url": repo.url, "name": repo.name, "branch": repo.branch})
repo_filename = pth / "cogs" / "RepoManager" / "repos.json" repo_filename = pth / "cogs" / "RepoManager" / "repos.json"
with open(str(repo_filename), "w") as f: with open(str(repo_filename), "w") as f: