Revert "Hash file for cache filename"

This commit is contained in:
Dylan Araps 2018-10-18 08:06:57 +11:00 committed by GitHub
parent f38d630a63
commit cfbd5353cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 14 deletions

View File

@ -4,6 +4,7 @@ Generate a palette using various backends.
import logging import logging
import os import os
import random import random
import re
import sys import sys
from . import theme from . import theme
@ -85,9 +86,9 @@ def saturate_colors(colors, amount):
def cache_fname(img, backend, light, cache_dir, sat=""): def cache_fname(img, backend, light, cache_dir, sat=""):
"""Create the cache file name.""" """Create the cache file name."""
color_type = "light" if light else "dark" color_type = "light" if light else "dark"
file_hash = util.hashf(img) file_name = re.sub("[/|\\|.]", "_", img)
file_parts = [file_hash, color_type, backend, sat, __cache_version__] file_parts = [file_name, color_type, backend, sat, __cache_version__]
return [cache_dir, "schemes", "%s_%s_%s_%s_%s.json" % (*file_parts,)] return [cache_dir, "schemes", "%s_%s_%s_%s_%s.json" % (*file_parts,)]

View File

@ -2,7 +2,6 @@
Misc helper functions. Misc helper functions.
""" """
import colorsys import colorsys
import hashlib
import json import json
import logging import logging
import os import os
@ -179,14 +178,3 @@ def get_pid(name):
return False return False
return True return True
def hashf(fpath):
"""Get the md5 hash of a file."""
return hashlib.md5(file_bytes(open(fpath, 'rb'))).hexdigest()
def file_bytes(fpath):
"""Helper function to read file."""
with fpath:
return fpath.read()