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):