parent
bbf4a8f89e
commit
1c3814e8e8
|
@ -0,0 +1,63 @@
|
|||
From: 5hir0kur0 <12101162+5hir0kur0@users.noreply.github.com>
|
||||
Date: Thu, 5 Mar 2020 10:04:59 +0100
|
||||
Subject: [PATCH] Fix crashes when deleting to trash
|
||||
|
||||
The execute() method of the trash command (in ranger/config/commands.py)
|
||||
used to pass a list of file paths (as strings) to fm.execute_file().
|
||||
|
||||
The documentation of the execute_file() method states that the 'files'
|
||||
parameter must not be strings:
|
||||
[...]
|
||||
files: a list of file objects (not strings!)
|
||||
[...]
|
||||
|
||||
So I changed 'files' to be a list of File objects and that seems to fix the
|
||||
issue.
|
||||
|
||||
Fixes #1798
|
||||
---
|
||||
ranger/config/commands.py | 11 +++++++----
|
||||
1 file changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
|
||||
index 5defa677..a2d13542 100755
|
||||
--- a/ranger/config/commands.py
|
||||
+++ b/ranger/config/commands.py
|
||||
@@ -722,13 +722,15 @@ class trash(Command):
|
||||
def execute(self):
|
||||
import shlex
|
||||
from functools import partial
|
||||
+ from ranger.container.file import File
|
||||
|
||||
def is_directory_with_files(path):
|
||||
return os.path.isdir(path) and not os.path.islink(path) and len(os.listdir(path)) > 0
|
||||
|
||||
if self.rest(1):
|
||||
- files = shlex.split(self.rest(1))
|
||||
- many_files = (len(files) > 1 or is_directory_with_files(files[0]))
|
||||
+ file_names = shlex.split(self.rest(1))
|
||||
+ files = [File(name) for name in file_names]
|
||||
+ many_files = (len(files) > 1 or is_directory_with_files(files[0].path))
|
||||
else:
|
||||
cwd = self.fm.thisdir
|
||||
tfile = self.fm.thisfile
|
||||
@@ -736,14 +738,15 @@ class trash(Command):
|
||||
self.fm.notify("Error: no file selected for deletion!", bad=True)
|
||||
return
|
||||
|
||||
+ files = self.fm.thistab.get_selection()
|
||||
# relative_path used for a user-friendly output in the confirmation.
|
||||
- files = [f.relative_path for f in self.fm.thistab.get_selection()]
|
||||
+ file_names = [f.relative_path for f in files]
|
||||
many_files = (cwd.marked_items or is_directory_with_files(tfile.path))
|
||||
|
||||
confirm = self.fm.settings.confirm_on_delete
|
||||
if confirm != 'never' and (confirm != 'multiple' or many_files):
|
||||
self.fm.ui.console.ask(
|
||||
- "Confirm deletion of: %s (y/N)" % ', '.join(files),
|
||||
+ "Confirm deletion of: %s (y/N)" % ', '.join(file_names),
|
||||
partial(self._question_callback, files),
|
||||
('n', 'N', 'y', 'Y'),
|
||||
)
|
||||
--
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# Template file for 'ranger'
|
||||
pkgname=ranger
|
||||
version=1.9.4
|
||||
revision=3
|
||||
revision=4
|
||||
build_style=python3-module
|
||||
hostmakedepends="python3 python3-setuptools"
|
||||
makedepends="python3-devel"
|
||||
|
|
Loading…
Reference in New Issue