diff --git a/oshipka/persistance/__init__.py b/oshipka/persistance/__init__.py index 0e9fbc1..64834cc 100644 --- a/oshipka/persistance/__init__.py +++ b/oshipka/persistance/__init__.py @@ -3,6 +3,7 @@ import datetime import json import os import re +from distutils import dir_util from importlib import import_module from json import JSONEncoder from uuid import uuid4 @@ -10,7 +11,7 @@ from uuid import uuid4 from flask import request from flask_security import current_user -from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE, SEARCH_INDEX_PATH, STATIC_DATA_DIR, basepath +from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE, SEARCH_INDEX_PATH, STATIC_DATA_DIR, MEDIA_DIR, basepath from flask_migrate import Migrate from flask_migrate import upgrade as migrate_upgrade from flask_migrate import init as migrate_init @@ -304,6 +305,9 @@ SENSITIVE_PREFIX = "__SENSITIVE__." def populate_static(app): + static_media_dir = os.path.join(STATIC_DATA_DIR, "media") + if os.path.exists(static_media_dir): + dir_util.copy_tree(static_media_dir, MEDIA_DIR) with app.app_context(): models = import_module("webapp.models") sensitive = import_module("sensitive")