Start: Correct hash for thumbnail filename (py3)

Image file names need to be quoted before hashing to generate thumbnail file names. This is related to pull requests #4931 and #4972, so please refer to discussions therein. Only Python3 is supported, not Python2.
This commit is contained in:
川島和津実
2021-08-18 22:27:39 +08:00
committed by GitHub
parent 3b6c442187
commit a95e9549a6

View File

@@ -109,14 +109,8 @@ def getInfo(filename):
import gnomevfs
except Exception:
# alternative method
import hashlib,sys
if sys.version_info.major < 3:
import urllib
hashload = urllib.quote("file://"+path,safe=":/")
else:
import urllib.parse
hashload = bytes(urllib.parse.quote("file://"+path,safe=":/"),"ascii")
fhash = hashlib.md5(hashload).hexdigest()
import hashlib,urllib.parse
fhash = hashlib.md5(bytes(urllib.parse.quote("file://"+path,safe=":/"),"ascii")).hexdigest()
thumb = os.path.join(os.path.expanduser("~"),".thumbnails","normal",fhash+".png")
else:
uri = gnomevfs.get_uri_from_local_path(path)