[Zope-dev] Win32: BUG + FIX
Anthony Pfrunder
s341625@student.uq.edu.au
Tue, 22 Jun 1999 16:40:38 +1000 (GMT+1000)
Hi,
I've finally fixed the corrupted database problem on Windows. This occurs
when you delete Data.fs and involves the transation engine not correctly
initalising the database when it is created. This results in all records
having the same datetime, hence causing lots of problems.
This patch works by manually setting the create flag if the file doesn't
exist. Also, directly after writing the first record it closes Data.fs
allowing it to be re-opened to read the (now existing) first record.
The patch:
******************************** Cut here **************************
File: \lib\python\Zodb\FileStorage.py: line 195
class FileStorage:
_packt=0
_transaction=None
_serial=z64
def __init__(self, file_name, create=0, log=lambda s: None,
read_only=0,
stop=None):
+ # Windows database hack:
+ # if db file doesn't exist then set create mode
+ if not(os.path.exists(file_name)):
+ create = 1
if read_only:
if create:
raise ValueError, "can\'t create a read-only file"
elif stop is not None:
raise ValueError, "time-travel is only supported in read-only
mode"
# Now open the file
************************************ Cut here *************************
File \lib\python\Zodb\FileStorage.py: line 248
if create:
if os.path.exists(file_name): os.remove(file_name)
self._file=file=open(file_name,'w+b')
self._file.write(packed_version)
self._pos=4
self._oid='\0\0\0\0\0\0\0\0'
+ # was return, instead, close file and allow it to be reopened
+ file.close()
Cheers,
Anthony Pfrunder