parent
39077092c0
commit
9d38d5d45e
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue