Skip to content

Commit

Permalink
Delete release and screenshot uploads immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Jan 18, 2024
1 parent 9ff7567 commit 6bb6a7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/blueprints/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import math
import os
from functools import wraps
from typing import List

Expand Down Expand Up @@ -343,6 +344,8 @@ def delete_release(token: APIToken, package: Package, id: int):
db.session.delete(release)
db.session.commit()

os.remove(release.file_path)

return jsonify({"success": True})


Expand Down Expand Up @@ -414,6 +417,8 @@ def delete_screenshot(token: APIToken, package: Package, id: int):
db.session.delete(ss)
db.session.commit()

os.remove(ss.file_path)

return jsonify({ "success": True })


Expand Down
3 changes: 3 additions & 0 deletions app/blueprints/packages/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
# 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/>.
import os

from flask import render_template, request, redirect, flash, url_for, abort
from flask_babel import lazy_gettext, gettext
Expand Down Expand Up @@ -241,6 +242,8 @@ def delete_release(package, id):
db.session.delete(release)
db.session.commit()

os.remove(release.file_path)

return redirect(package.get_url("packages.view"))


Expand Down
3 changes: 3 additions & 0 deletions app/blueprints/packages/screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
# 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/>.
import os

from flask import render_template, request, redirect, flash, url_for, abort
from flask_babel import lazy_gettext, gettext
Expand Down Expand Up @@ -143,4 +144,6 @@ def delete_screenshot(package, id):
db.session.delete(screenshot)
db.session.commit()

os.remove(screenshot.file_path)

return redirect(package.get_url("packages.screenshots"))

0 comments on commit 6bb6a7a

Please sign in to comment.