about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/actions.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index d7ead160..ba31db58 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -20,6 +20,7 @@ from hashlib import sha512
 from logging import getLogger
 
 import ranger
+from ranger import PY3
 from ranger.container.directory import Directory
 from ranger.container.file import File
 from ranger.container.settings import ALLOWED_SETTINGS, ALLOWED_VALUES
@@ -1022,10 +1023,10 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
     def sha512_encode(path, inode=None):
         if inode is None:
             inode = stat(path).st_ino
-        sha = sha512(
-            "{0}{1}".format(path, str(inode)).encode('utf-8', 'backslashescape')
-        )
-        return '{0}.jpg'.format(sha.hexdigest())
+        inode_path = "{0}{1}".format(str(inode), path)
+        if PY3:
+            inode_path = inode_path.encode('utf-8', 'backslashescape')
+        return '{0}.jpg'.format(sha512(inode_path).hexdigest())
 
     def get_preview(self, fobj, width, height):
         # pylint: disable=too-many-return-statements,too-many-statements