Skip to content

Commit

Permalink
Correct hashing of utf8 files
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jul 6, 2015
1 parent a81b233 commit d252369
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/dots
Expand Up @@ -518,8 +518,12 @@ class ConfigFile(object):

# Test that the file hasn't changed
if os.path.exists(path):
installed = hashlib.md5(open(path).read()).digest()
compiled = hashlib.md5(''.join(self.compiled)).digest()
compiled = ''.join(self.compiled).encode('utf-8')
compiled = hashlib.md5(compiled).digest()

with open(path, 'r', encoding='utf-8') as installed_file:
installed = installed_file.read().encode('utf-8')
installed = hashlib.md5(installed).digest()

if installed == compiled and os.stat(path).st_mode == self.mode():
return
Expand Down

0 comments on commit d252369

Please sign in to comment.