1
mirror of git://git.acid.vegas/scroll.git synced 2024-11-07 08:46:45 +00:00

Fixed database syncing from not parsing the correct tree sha

This commit is contained in:
Dionysus 2023-06-06 22:22:20 -04:00
parent a67d02291e
commit 7e492906c2
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE

View File

@ -110,16 +110,19 @@ class Bot():
else: else:
await self.listen() await self.listen()
finally: finally:
for item in self.loops:
if self.loops[item]:
self.loops[item].cancel()
self.loops = dict() self.loops = dict()
self.playing = False self.playing = False
self.slow = False self.slow = False
await asyncio.sleep(30) await asyncio.sleep(30)
async def sync(self): async def sync(self):
cache = self.db
self.db = {'root':list()}
try: try:
cache = self.db sha = [item['sha'] for item in json.loads(urllib.request.urlopen('https://api.github.com/repos/ircart/ircart/contents').read().decode('utf-8')) if item['path'] == 'ircart'][0]
self.db = {'root':list()}
sha = json.loads(urllib.request.urlopen('https://api.github.com/repos/ircart/ircart/contents').read().decode('utf-8'))[1]['sha']
files = json.loads(urllib.request.urlopen(f'https://api.github.com/repos/ircart/ircart/git/trees/{sha}?recursive=true').read().decode('utf-8'))['tree'] files = json.loads(urllib.request.urlopen(f'https://api.github.com/repos/ircart/ircart/git/trees/{sha}?recursive=true').read().decode('utf-8'))['tree']
for file in files: for file in files:
if file['type'] != 'tree': if file['type'] != 'tree':