From ce76c868a4ec3df09109ccb994fdf506f2f0e903 Mon Sep 17 00:00:00 2001 From: Agnibho Mondal Date: Thu, 14 Sep 2023 03:28:52 +0530 Subject: [PATCH] Bugfix: remove attachment --- filehandler.py | 8 +++++++- window.py | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/filehandler.py b/filehandler.py index 48aa5d5..63d6b03 100644 --- a/filehandler.py +++ b/filehandler.py @@ -81,12 +81,18 @@ class FileHandler(): except FileNotFoundError as e: print(e) + def delete_attachment(self, item): + try: + os.unlink(os.path.join(self.directory.name, "attachment", os.path.basename(item))) + except Exception as e: + print(e) + def delete_sign(self): try: os.unlink(os.path.join(self.directory.name, "certificate.pem")) os.unlink(os.path.join(self.directory.name, "signature.p7m")) except Exception as e: - raise(e) + print(e) def is_signed(self): return(os.path.exists(os.path.join(self.directory.name, "certificate.pem")) and (os.path.exists(os.path.join(self.directory.name, "signature.p7m")))) diff --git a/window.py b/window.py index d26f0f1..b1843f6 100644 --- a/window.py +++ b/window.py @@ -355,7 +355,12 @@ class MainWindow(QMainWindow): print(e) def remove_attachment(self): - self.input_attachment.takeItem(self.input_attachment.currentRow()) + index=self.input_attachment.currentRow() + if(index>=0): + self.current_file.delete_attachment(self.input_attachment.item(index).text()) + self.input_attachment.takeItem(index) + else: + QMessageBox.warning(self, "Select item", "Please select an attachment to remove.") def save_attachment(self): try: -- 2.39.2