Delete release and screenshot uploads immediately

This commit is contained in:
rubenwardy 2024-01-18 18:28:36 +00:00
parent 9ff7567cde
commit 6bb6a7ae05
3 changed files with 11 additions and 0 deletions

@ -15,6 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
import math import math
import os
from functools import wraps from functools import wraps
from typing import List from typing import List
@ -343,6 +344,8 @@ def delete_release(token: APIToken, package: Package, id: int):
db.session.delete(release) db.session.delete(release)
db.session.commit() db.session.commit()
os.remove(release.file_path)
return jsonify({"success": True}) return jsonify({"success": True})
@ -414,6 +417,8 @@ def delete_screenshot(token: APIToken, package: Package, id: int):
db.session.delete(ss) db.session.delete(ss)
db.session.commit() db.session.commit()
os.remove(ss.file_path)
return jsonify({ "success": True }) return jsonify({ "success": True })

@ -13,6 +13,7 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
from flask import render_template, request, redirect, flash, url_for, abort from flask import render_template, request, redirect, flash, url_for, abort
from flask_babel import lazy_gettext, gettext from flask_babel import lazy_gettext, gettext
@ -241,6 +242,8 @@ def delete_release(package, id):
db.session.delete(release) db.session.delete(release)
db.session.commit() db.session.commit()
os.remove(release.file_path)
return redirect(package.get_url("packages.view")) return redirect(package.get_url("packages.view"))

@ -13,6 +13,7 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
from flask import render_template, request, redirect, flash, url_for, abort from flask import render_template, request, redirect, flash, url_for, abort
from flask_babel import lazy_gettext, gettext from flask_babel import lazy_gettext, gettext
@ -143,4 +144,6 @@ def delete_screenshot(package, id):
db.session.delete(screenshot) db.session.delete(screenshot)
db.session.commit() db.session.commit()
os.remove(screenshot.file_path)
return redirect(package.get_url("packages.screenshots")) return redirect(package.get_url("packages.screenshots"))