-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CytubeBot fails to create a working database #51
Comments
Rank should be added when it updates the tables though. https://github.com/nuclearace/CytubeBot/blob/master/lib/database.js#L40 |
For me, it crashed before it got to that point. |
The database initialization code is fragile and has race conditions. What probably happened is the disk was slow and the network was fast so the bot joined the room and got the list of users before running
The trick for #1 is to lock the database during initialization but not require threads to acquire locks after that point or you'll remove any parallelism. |
When CytubeBot creates it's database, it does it in such a way that it'll crash when it tries to supply values to the users table. I have fixed this on my own machine by manually dropping the users table and creating a new one with this command:
CREATE TABLE users(uname TEXT, blacklisted TEXT, block TEXT, rank INTEGER, primary key(uname));
I believe the bug exists in line 22 of lib/database.js, which reads:
this.db.run("CREATE TABLE IF NOT EXISTS users(uname TEXT, blacklisted TEXT, block TEXT, primary key(uname))")
but should read:
this.db.run("CREATE TABLE IF NOT EXISTS users(uname TEXT, blacklisted TEXT, block TEXT, rank INTEGER, primary key(uname))")
Adding "rank INTEGER," which seems to have been left out.
The text was updated successfully, but these errors were encountered: