[meld] dirdiff, vcview: Allow deleting files from remote filesystem
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] dirdiff, vcview: Allow deleting files from remote filesystem
- Date: Sat, 24 Mar 2018 22:20:27 +0000 (UTC)
commit 982cc2b586d68f86f549a9d4a4d7bc936575c58f
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Dec 16 11:36:11 2017 +1000
dirdiff, vcview: Allow deleting files from remote filesystem
Patch from Colleen Johnson <linux_rocks msn com>
meld/dirdiff.py | 18 +++++++++++++++++-
meld/vcview.py | 18 +++++++++++++++++-
2 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 7890374d..0d9cf9ae 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -993,7 +993,23 @@ class DirDiff(MeldDoc, Component):
gfile.trash(None)
self.file_deleted(path, pane)
except GLib.GError as e:
- misc.error_dialog(_("Error deleting %s") % name, str(e))
+ try:
+ # Gio will fail if trash doesn't exist - so try and
+ # just delete.
+ # Delete using regular python since we can delete
+ # the whole tree this way - for Gio all files would
+ # have to be removed - this is simpler
+ # NOTE: if a file doesn't have write permission and
+ # the user owns it, it will get deleted anyway
+ if (os.path.exists(name)):
+ if (os.path.isfile(name)):
+ os.remove(name)
+ self.file_deleted(path, pane)
+ else:
+ shutil.rmtree(name)
+ self.file_deleted(path, pane)
+ except OSError as e:
+ misc.error_dialog(_("Error deleting %s") % name, str(e))
def on_treemodel_row_deleted(self, model, path):
if self.current_path == path:
diff --git a/meld/vcview.py b/meld/vcview.py
index cdfb939c..6d94610b 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -699,7 +699,23 @@ class VcView(MeldDoc, Component):
gfile = Gio.File.new_for_path(name)
gfile.trash(None)
except GLib.GError as e:
- error_dialog(_("Error removing %s") % name, str(e))
+ try:
+ # Gio will fail if trash doesn't exist - so try and
+ # just delete.
+ # Delete using regular python since we can delete
+ # the whole tree this way - for Gio all files would
+ # have to be removed - this is simpler
+ # NOTE: if a file doesn't have write permission and
+ # the user owns it, it will get deleted anyway
+ if (os.path.exists(name)):
+ if (os.path.isfile(name)):
+ os.remove(name)
+ self.file_deleted(path, pane)
+ else:
+ shutil.rmtree(name)
+ self.file_deleted(path, pane)
+ except OSError as e:
+ error_dialog(_("Error deleting %s") % name, str(e))
workdir = os.path.dirname(os.path.commonprefix(files))
self.refresh_partial(workdir)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]