From af947ee3bc250985086a20bbd059a1a481689b5e Mon Sep 17 00:00:00 2001
From: Patrick Jentsch <pjentsch@sfb1288inf-Laptop.fritz.box>
Date: Fri, 10 Jul 2020 11:39:37 +0200
Subject: [PATCH] Use appropriate methods and variable naming

---
 web/app/models.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/web/app/models.py b/web/app/models.py
index d23a25ff..c3fe91d2 100644
--- a/web/app/models.py
+++ b/web/app/models.py
@@ -504,13 +504,13 @@ class CorpusFile(db.Model):
     title = db.Column(db.String(255))
 
     def delete(self):
-        corpus_file = os.path.join(current_app.config['NOPAQUE_STORAGE'],
-                                   str(self.corpus.user_id),
-                                   'corpora',
-                                   str(self.corpus_id),
-                                   self.filename)
+        corpus_file_path = os.path.join(current_app.config['NOPAQUE_STORAGE'],
+                                        str(self.corpus.user_id),
+                                        'corpora',
+                                        str(self.corpus_id),
+                                        self.filename)
         try:
-            os.remove(corpus_file)
+            os.remove(corpus_file_path)
         except OSError:
             pass
         db.session.delete(self)
@@ -632,7 +632,10 @@ class Result(db.Model):
     def delete(self):
         result_file_path = os.path.join(current_app.config['NOPAQUE_STORAGE'],
                                         self.file[0].dir)
-        shutil.rmtree(result_file_path)
+        try:
+            os.remove(result_file_path)
+        except OSError:
+            pass
         db.session.delete(self)
 
     def __repr__(self):
-- 
GitLab