From e0e0d5770f599ab928c91a53cc5bd805c16cce95 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 10 Mar 2019 20:57:36 +0100 Subject: Temporarily disable open_all_images if there are too many images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In extreme cases, all the images may be too much to handle by the system ("Argument list too long", errno 7). In such cases, let's Do The Right Thing™ and temporarily disable the open_all_images setting. Without this option we'll only open the single image. Fixes #1488. --- ranger/core/actions.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 8e98432a..6c98e363 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -410,7 +410,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m raise self.notify('Error in line `%s\':\n %s' % (line, str(ex)), bad=True) - def execute_file(self, files, **kw): + def execute_file(self, files, **kw): # pylint: disable=too-many-branches """Uses the "rifle" module to open/execute a file Arguments are the same as for ranger.ext.rifle.Rifle.execute: @@ -457,8 +457,22 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m self.signal_emit('execute.before', keywords=kw) filenames = [f.path for f in files] label = kw.get('label', kw.get('app', None)) - try: + + def execute(): return self.rifle.execute(filenames, mode, label, flags, None) + try: + return execute() + except OSError as err: + # Argument list too long. + if err.errno == 7 and self.settings.open_all_images: + old_value = self.settings.open_all_images + try: + self.settings.open_all_images = False + return execute() + finally: + self.settings.open_all_images = old_value + else: + raise finally: self.signal_emit('execute.after') -- cgit 1.4.1-2-gfad0 From 6d56f200f2be981542ee71bc53defe62ed729f09 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 10 Mar 2019 21:45:44 +0100 Subject: Add a notification for the open_all_images autodisabling --- ranger/core/actions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6c98e363..75697696 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -467,6 +467,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if err.errno == 7 and self.settings.open_all_images: old_value = self.settings.open_all_images try: + self.notify("Too many files: Disabling open_all_images temporarily.") self.settings.open_all_images = False return execute() finally: -- cgit 1.4.1-2-gfad0 From fcccf1c20333e1d223346d3e3dda4e3fac197d3b Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 10 Mar 2019 21:46:16 +0100 Subject: Update the manpage --- doc/ranger.1 | 7 +++++-- doc/ranger.pod | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 7604e124..f7b853c6 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) +.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "2019-02-24" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2019-03-10" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -945,6 +945,9 @@ Start line numbers from 1. Possible values are: .IX Item "open_all_images [bool]" Open all images in this directory when running certain image viewers like feh or sxiv? You can still open selected files by marking them. +.Sp +If there will be too many files for the system to handle, this option +will be temporarily disabled automatically. .IP "padding_right [bool]" 4 .IX Item "padding_right [bool]" When collapse_preview is on and there is no preview, should there remain a diff --git a/doc/ranger.pod b/doc/ranger.pod index 3b9b92fc..770fe4aa 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -967,6 +967,9 @@ Start line numbers from 1. Possible values are: Open all images in this directory when running certain image viewers like feh or sxiv? You can still open selected files by marking them. +If there will be too many files for the system to handle, this option +will be temporarily disabled automatically. + =item padding_right [bool] When collapse_preview is on and there is no preview, should there remain a -- cgit 1.4.1-2-gfad0 From 57986303066ebbacbea5e103ba75719e030e081d Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 10 Mar 2019 23:17:39 +0100 Subject: Phrasing change --- doc/ranger.1 | 2 +- doc/ranger.pod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index f7b853c6..09bd94a4 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -946,7 +946,7 @@ Start line numbers from 1. Possible values are: Open all images in this directory when running certain image viewers like feh or sxiv? You can still open selected files by marking them. .Sp -If there will be too many files for the system to handle, this option +If there would be too many files for the system to handle, this option will be temporarily disabled automatically. .IP "padding_right [bool]" 4 .IX Item "padding_right [bool]" diff --git a/doc/ranger.pod b/doc/ranger.pod index 770fe4aa..e3419d0f 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -967,7 +967,7 @@ Start line numbers from 1. Possible values are: Open all images in this directory when running certain image viewers like feh or sxiv? You can still open selected files by marking them. -If there will be too many files for the system to handle, this option +If there would be too many files for the system to handle, this option will be temporarily disabled automatically. =item padding_right [bool] -- cgit 1.4.1-2-gfad0