diff --git a/overwrought_master.py b/overwrought_master.py old mode 100644 new mode 100755 index 3f21ad2..acc07a8 --- a/overwrought_master.py +++ b/overwrought_master.py @@ -255,7 +255,7 @@ def post_pack(): for mod in mods: files[mod.filename] = open(os.path.join('mods', mod.filename), 'rb') files[config_master.modpack_name + '.html'] = open( - config_master.modpack_name, 'rb') + config_master.modpack_name +'.html', 'rb') res = requests.post( url=config_master.remote_addr + '/post', diff --git a/overwrought_server.py b/overwrought_server.py old mode 100644 new mode 100755 index 1b1dbee..9222a1f --- a/overwrought_server.py +++ b/overwrought_server.py @@ -2,6 +2,7 @@ """ The overwrought server, for exchanging mods from master to slave recipients. """ +import os import json import sqlite3 import threading @@ -13,6 +14,22 @@ import config_server app = Flask(__name__) app.config['db_lock'] = threading.Lock() +os.makedirs('mods', exist_ok=True) + +def init_db(): + """ + If no database is found, a dummy database is created to allow the + initial modpack upload to go smoothly. + """ + con = sqlite3.connect('modpack.db') + cur = con.cursor() + try: + cur.execute("SELECT filename FROM mod").fetchone() + except sqlite3.OperationalError: + cur.execute("CREATE TABLE mod(filename TEXT)") + con.commit() + con.close() +init_db() @app.route('/') def index():