diff options
author | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2016-01-24 23:12:42 +0100 |
---|---|---|
committer | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2016-01-24 23:12:42 +0100 |
commit | deb16c1da3b0301a04487e2bfb753536176264c8 (patch) | |
tree | 86015bf53d5f021ae155d809cdc3827cbf2f1840 /ranger | |
parent | 6c9e8657537bc03dbab0cbfbfe6e1ce3887759a7 (diff) | |
download | ranger-deb16c1da3b0301a04487e2bfb753536176264c8.tar.gz |
Move some :delete logic to fm.delete, further refactoring
Diffstat (limited to 'ranger')
-rwxr-xr-x | ranger/config/commands.py | 13 | ||||
-rw-r--r-- | ranger/core/actions.py | 29 |
2 files changed, 19 insertions, 23 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 98cf0cdf..eb4ee4c3 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -548,23 +548,14 @@ class delete(Command): partial(self._question_callback, files), ('n', 'N', 'y', 'Y')) else: # no need for a confirmation, just delete - self._delete_with_tags(files) + self.fm.delete(files) def tab(self, tabnum): return self._tab_directory_content() - def _delete_with_tags(self, files): - # Delete the selected files and untag them. - absolute_files = [os.path.abspath(f) for f in files] - for f in absolute_files: - for tag in self.fm.tags.tags: - if str(tag).startswith(os.path.abspath(f)): - self.fm.tags.remove(tag) - self.fm.delete(absolute_files) - def _question_callback(self, files, answer): if answer == 'y' or answer == 'Y': - self._delete_with_tags(files) + self.fm.delete(files) class mark_tag(Command): diff --git a/ranger/core/actions.py b/ranger/core/actions.py index e45326f3..a9618746 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1309,19 +1309,24 @@ class Actions(FileManagerAware, SettingsAware): def delete(self, files): # XXX: warn when deleting mount points/unseen marked files? self.notify("Deleting!") + files = [os.path.abspath(f) for f in files] + for f in files: + # Untag the deleted files. + for tag in self.fm.tags.tags: + if str(tag).startswith(f): + self.fm.tags.remove(tag) self.copy_buffer = set(filter(lambda f: f.path not in files, self.copy_buffer)) - if files: - for f in files: - if isdir(f) and not os.path.islink(f): - try: - shutil.rmtree(f) - except OSError as err: - self.notify(err) - else: - try: - os.remove(f) - except OSError as err: - self.notify(err) + for f in files: + if isdir(f) and not os.path.islink(f): + try: + shutil.rmtree(f) + except OSError as err: + self.notify(err) + else: + try: + os.remove(f) + except OSError as err: + self.notify(err) self.thistab.ensure_correct_pointer() def mkdir(self, name): |