From 3a38f7ed6dc83af317971a60c1eefa021cfb8753 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 1 Oct 2020 16:59:15 +0200 Subject: [PATCH] Fix crash on delete (2) --- pynyaata/__init__.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pynyaata/__init__.py b/pynyaata/__init__.py index 313a8f0..92e27f7 100644 --- a/pynyaata/__init__.py +++ b/pynyaata/__init__.py @@ -108,13 +108,9 @@ def list_animes(url_filters='nyaa,yggtorrent'): def remove_garbage(link): title = link.title - if title: - if not len(title.links): - db.session.delete(title) - db.session.commit() - if not len(title.folder.titles): - db.session.delete(title.folder) - db.session.commit() + if title and not len(title.links): + db.session.delete(title) + db.session.commit() @app.route('/admin', methods=['GET', 'POST'])