summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChristian Zangl <christian.zangl@s-versicherung.at>2017-01-23 00:07:18 +0100
committernfnty <git@nfnty.se>2017-01-23 18:25:15 +0100
commit9f5c0d631ba08d2583898c82c05cfdad8fd52dd8 (patch)
tree13ed457cbf72a3c64a446e136c2cd42a0984217d
parent79deadc7a9662807c075e3c61f3eb9362e29683c (diff)
downloadranger-9f5c0d631ba08d2583898c82c05cfdad8fd52dd8.tar.gz
core.linemode: `Mtime`: Fix crash when `file.stat is None`
This can happen with Bash on Windows for files without permission
and on OSX/Linux when deleting files.

Fixes #741
Fixes #769
-rw-r--r--ranger/core/linemode.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index 8d53a9f8..e4c6c3a4 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -119,6 +119,8 @@ class MtimeLinemode(LinemodeBase):
         return fobj.relative_path
 
     def infostring(self, fobj, metadata):
+        if fobj.stat is None:
+            return '?'
         return datetime.fromtimestamp(fobj.stat.st_mtime).strftime("%Y-%m-%d %H:%M")
 
 
@@ -129,5 +131,7 @@ class SizeMtimeLinemode(LinemodeBase):
         return fobj.relative_path
 
     def infostring(self, fobj, metadata):
+        if fobj.stat is None:
+            return '?'
         return "%s %s" % (human_readable(fobj.size),
                           datetime.fromtimestamp(fobj.stat.st_mtime).strftime("%Y-%m-%d %H:%M"))