summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-08-05 14:29:00 +0200
committerhut <hut@lavabit.com>2012-08-05 14:29:00 +0200
commita1be5fc881e1378d5133fa6244e9f72a3dfc5508 (patch)
tree762757b5ecbdcfcd2a7c8a07023d40443acd0c06 /ranger
parentb0314dd1e836763d864021d7adfb128196186c6a (diff)
downloadranger-a1be5fc881e1378d5133fa6244e9f72a3dfc5508.tar.gz
core.actions: More reliable mimetype checking @ execute_file
This is a result of https://github.com/hut/ranger/issues/43 :

adam8157:
  Hmm... I found this behavior is different between running in Debian Sid
  and Fedora 17.

  Their python version are both 2.7.3, but when you touch a file named
  foo.sh, and press "r", ranger in Fedora 17 displays bash as the first
  opener, then editor and pager, but ranger in Debian Sid displays editor
  first, then pager and bash.

[...]

hut:
  Ok, with your help I found it. Actions.execute_file and
  Actions.draw_possible_programs optimize the process by skipping the call
  to file --mimetype -Lb and using the mime type that the python mimetypes
  library found. The two methods return different mimetypes sometimes.
  Since file is more reliable than the python mimetypes library, I'll
  change it to use file always.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/actions.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 73e8bb67..0d76f2e8 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -292,10 +292,9 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 
 		self.signal_emit('execute.before', keywords=kw)
 		filenames = [f.path for f in files]
-		mimetype = files[0].mimetype if files else None
 		label = kw.get('label', kw.get('app', None))
 		try:
-			return self.rifle.execute(filenames, mode, label, flags, mimetype)
+			return self.rifle.execute(filenames, mode, label, flags, None)
 		finally:
 			self.signal_emit('execute.after')
 
@@ -684,7 +683,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		except:
 			self.ui.browser.draw_info = []
 			return
-		programs = self.rifle.list_commands([target.path], target.mimetype)
+		programs = self.rifle.list_commands([target.path], None)
 		programs = ['%s | %s' % program[0:2] for program in programs]
 		self.ui.browser.draw_info = programs