From e4b00b04e95f1ed2a0af508a0fb6635d7cda1a91 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sat, 10 Jul 2021 23:51:07 +0200 Subject: [PATCH] Fix garbage --- pynyaata/__init__.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py index 3459835..b51a848 100644 --- a/pynyaata/__init__.py +++ b/pynyaata/__init__.py @@ -114,13 +114,6 @@ def list_animes(url_filters='nyaa,yggtorrent'): return render_template('list.html', search_form=SearchForm(), titles=results) -def remove_garbage(link): - title = link.title - if title and not len(title.links): - db.session.delete(title) - db.session.commit() - - @app.route('/admin', methods=['GET', 'POST']) @mysql_required @auth.login_required @@ -133,7 +126,11 @@ def admin(): form.message = '%s (%s) has been successfully deleted' % (link.title.name, link.season) db.session.delete(link) db.session.commit() - remove_garbage(link) + + title = link.title + if title and not len(title.links): + db.session.delete(title) + db.session.commit() else: form._errors = {'id': ['Id %s was not found in the database' % form.id.data]} @@ -230,7 +227,6 @@ def admin_edit(link_id=None): # Database db.session.add(link) db.session.commit() - remove_garbage(link) # Transmission if TRANSMISSION_ENABLED and isinstance(instance, Nyaa):