Fix initial user creation.

sqlite3.connect automatically creates a database file if it doesn't
exist yet. Consequently, os.path.isfile will always return true, the
auth table won't be created, and inserting a user will fail.
This commit is contained in:
Alexander Grüneberg 2013-12-05 17:18:17 -06:00 committed by jdoe0
parent 33c0fdcd1f
commit d23dd0122a

View File

@ -69,8 +69,7 @@ def adduser(username):
conn = sqlite3.connect(AUTHDBPATH)
cursor = conn.cursor()
if not os.path.isfile(AUTHDBPATH):
cursor.execute( "CREATE TABLE auth "
cursor.execute( "CREATE TABLE IF NOT EXISTS auth "
"(user VARCHAR PRIMARY KEY, hash VARCHAR)")
cursor.execute("INSERT INTO auth VALUES (?, ?)", (username, hash))