From 9d38d5d45eabf1abff4352d9d4b3ce2ab83c6689 Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 9 Nov 2008 22:28:25 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- buffer/__init__.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/buffer/__init__.py b/buffer/__init__.py index 2331af2..13d19a5 100644 --- a/buffer/__init__.py +++ b/buffer/__init__.py @@ -1,4 +1,4 @@ -import codecs, datetime, grp, hashlib, os, pwd, re, shutil, stat, string +import codecs, datetime, grp, os, pwd, re, shutil, stat, string import fcntl, select, pty, threading import aes, dirutil, regex, highlight, lex, term from point import Point @@ -12,6 +12,15 @@ ACT_UNDO = 1 ACT_REDO = 2 STACK_LIMIT = 1024 +def hasher(data): + try: + import hashlib + m = hashlib.md5(data) + except: + import md5 + m = md5.new(data) + return m + class ReadOnlyError(Exception): pass @@ -582,7 +591,8 @@ class FileBuffer(Buffer): return os.path.exists(self.path) def store_checksum(self, data): #self.checksum = md5.new(data) - self.checksum = hashlib.md5(data) + #self.checksum = hashlib.md5(data) + self.checksum = hasher(data) def read(self): if self.path_exists(): f = self._open_file_r() @@ -620,7 +630,8 @@ class FileBuffer(Buffer): data = f.read() f.close() #m = md5.new(data) - m = hashlib.md5(data) + #m = hashlib.md5(data) + m = hasher(data) return self.checksum.digest() != m.digest() def save(self, force=False): if self.readonly():