From 19ff5c95b1c22d856a94a80bb64577098ce6e0b2 Mon Sep 17 00:00:00 2001 From: phxntxm Date: Wed, 28 Sep 2016 19:23:29 -0500 Subject: [PATCH] Corrected error where content was being overwritten --- cogs/utils/config.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/cogs/utils/config.py b/cogs/utils/config.py index 3248253..b8a37e2 100644 --- a/cogs/utils/config.py +++ b/cogs/utils/config.py @@ -175,19 +175,13 @@ async def add_content(table, content, r_filter=None): try: if r_filter is not None: cursor = await r.table(table).filter(r_filter).run(conn) - content = await _convert_to_list(cursor) - if len(content) > 0: + cur_content = await _convert_to_list(cursor) + if len(cur_content) > 0: await conn.close() return False - else: - await r.table(table).insert(content).run(conn) - await conn.close() - return True - - else: - await r.table(table).insert(content).run(conn) - await conn.close() - return True + await r.table(table).insert(content).run(conn) + await conn.close() + return True except r.ReqlOpFailedError: # This means the table does not exist await r.create_table(table).run(conn)