about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2019-03-11 00:07:15 +0100
committerGitHub <noreply@github.com>2019-03-11 00:07:15 +0100
commit279931800be60e7da3b94649a0923d0a2f678e38 (patch)
treeb7a4d71b6e7725585d131e5513120ce1490b0fac
parentf70c6560b6e950168b0b4481e1f20a7df121d60d (diff)
parent57986303066ebbacbea5e103ba75719e030e081d (diff)
downloadranger-279931800be60e7da3b94649a0923d0a2f678e38.tar.gz
Merge pull request #1490 from Vifon/open_all_images_dwim
Temporarily disable open_all_images if there are too many images
-rw-r--r--doc/ranger.17
-rw-r--r--doc/ranger.pod3
-rw-r--r--ranger/core/actions.py19
3 files changed, 25 insertions, 4 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 7604e124..09bd94a4 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 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]"
 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..e3419d0f 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 would 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
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 8e98432a..75697696 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,23 @@ 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.notify("Too many files: Disabling open_all_images temporarily.")
+                    self.settings.open_all_images = False
+                    return execute()
+                finally:
+                    self.settings.open_all_images = old_value
+            else:
+                raise
         finally:
             self.signal_emit('execute.after')