From aff9f89640cd3cb76f90013db2caec91e9e4f5d1 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 9 Dec 2020 09:48:15 -0800 Subject: [PATCH] be sure to delete post's image when deleting from route --- suchwow/routes/post.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/suchwow/routes/post.py b/suchwow/routes/post.py index 3b1926f..3f39166 100644 --- a/suchwow/routes/post.py +++ b/suchwow/routes/post.py @@ -1,4 +1,4 @@ -from os import path +from os import path, remove from flask import render_template, Blueprint, request, session, flash from flask import send_from_directory, redirect, url_for, current_app from werkzeug.utils import secure_filename @@ -123,6 +123,9 @@ def delete(id): if filtered: post = filtered.first() if user == post.submitter or is_mod: + save_path_base = path.join(current_app.config["DATA_FOLDER"], "uploads") + save_path = path.join(save_path_base, post.image_name) + remove(save_path) post.delete_instance() flash("Deleted that shit, brah!") if is_mod: