From 7809e45bbf3ead29497d319ed1be340dfcb99800 Mon Sep 17 00:00:00 2001 From: Erriez Date: Sun, 5 Mar 2023 12:41:06 +0100 Subject: [PATCH] Check write permission wipe path --- examples/shred.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/shred.py b/examples/shred.py index 9381fa6..bf71043 100644 --- a/examples/shred.py +++ b/examples/shred.py @@ -40,6 +40,7 @@ def shred_menu_activate_cb(self, menu, data): flags=0, message_type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO, + title="Caja shred", text="Are you sure you want to shred selected files?", ) dialog.format_secondary_text("WARNING: This cannot be undone!") @@ -58,6 +59,20 @@ def wipe_freepsace_menu_activate_cb(self, menu, data): wipe_cmd = data['cmd'].replace('of=', 'of={}/'.format(wipe_path)) clean_cmd = 'rm {}/{}'.format(wipe_path, self.WIPE_FILENAME) + # Check if wipe path is writable + if not os.access(wipe_path, os.W_OK): + dialog = Gtk.MessageDialog( + parent=None, + flags=0, + message_type=Gtk.MessageType.ERROR, + buttons=Gtk.ButtonsType.OK, + title="Caja wipe freespace", + text="Error: Directory is not writable", + ) + response = dialog.run() + dialog.destroy() + return + # Start wipe freespace command print('Running: {}'.format(wipe_cmd)) try: @@ -77,6 +92,7 @@ def wipe_freepsace_menu_activate_cb(self, menu, data): flags=0, message_type=Gtk.MessageType.INFO, buttons=Gtk.ButtonsType.OK, + title="Caja wipe freespace", text="Wipe freespace completed!", ) response = dialog.run()