~craftyguy/ridecasa

bceec71d07e806d7fac8e8ddaf9fbac48d7d1c1d — Clayton Craft 3 years ago 59e2e3e
user/file_upload: add env var for setting tmp dir

When run in containers, the tmp dir needs to be shared between the
containers. This allows setting that dir in the application using
RIDECASA_TMP_DIR.
1 files changed, 5 insertions(+), 1 deletions(-)

M ridecasa/user/views.py
M ridecasa/user/views.py => ridecasa/user/views.py +5 -1
@@ 18,7 18,11 @@ user_blueprint = Blueprint('user', __name__,
@user_blueprint.route('/upload', methods=['POST'])
@login_required
def file_upload():
    dest_dir = tempfile.mkdtemp(prefix=f"tmp_ridecasa_{current_user.id}")
    # allow setting a subdir in /tmp for cases where importer and web backend
    # are different containers
    if (tmp_dir := os.environ.get('RIDECASA_TMP_DIR')) is None:
        tmp_dir = '/tmp'
    dest_dir = tempfile.mkdtemp(prefix=f"{tmp_dir}/tmp_ridecasa_{current_user.id}")

    # handle multiple files, or one
    files = []