From a1be5fc881e1378d5133fa6244e9f72a3dfc5508 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 5 Aug 2012 14:29:00 +0200 Subject: 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. --- ranger/core/actions.py | 5 ++--- 1 file 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 -- cgit 1.4.1-2-gfad0