From 60a1cf24b963bc8884e01eab646fe80f085e7b92 Mon Sep 17 00:00:00 2001 From: Ben Busby <33362396+benbusby@users.noreply.github.com> Date: Mon, 1 Jun 2020 11:37:49 -0600 Subject: [PATCH] Fixed issue with "de-pickling" of flask session Having a gitignore-everything ("*") file within a flask session folder seems to cause a weird bug where the state of the app becomes unusable from continuously trying to prune files listed in the gitignore (and it can't prune '*'). --- .gitignore | 1 + app/__init__.py | 5 ++++- app/static/config/.gitignore | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 app/static/config/.gitignore diff --git a/.gitignore b/.gitignore index 20307d1..f6e039f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__/ config.json test/static flask_session/ +app/static/config # pip stuff build/ diff --git a/app/__init__.py b/app/__init__.py index 4b0739b..857e93f 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -6,7 +6,7 @@ import os app = Flask(__name__, static_folder=os.path.dirname(os.path.abspath(__file__)) + '/static') app.user_elements = {} -app.config['SECRET_KEY'] = os.urandom(128) +app.config['SECRET_KEY'] = os.urandom(16) app.config['SESSION_TYPE'] = 'filesystem' app.config['VERSION_NUMBER'] = '0.1.4' app.config['APP_ROOT'] = os.getenv('APP_ROOT', os.path.dirname(os.path.abspath(__file__))) @@ -15,6 +15,9 @@ app.config['CONFIG_PATH'] = os.getenv('CONFIG_VOLUME', app.config['STATIC_FOLDER app.config['SESSION_FILE_DIR'] = app.config['CONFIG_PATH'] app.config['SESSION_COOKIE_SECURE'] = True +if not os.path.exists(app.config['CONFIG_PATH']): + os.makedirs(app.config['CONFIG_PATH']) + sess = Session() sess.init_app(app) diff --git a/app/static/config/.gitignore b/app/static/config/.gitignore deleted file mode 100644 index 72e8ffc..0000000 --- a/app/static/config/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*