[Zope-dev] Win32: BUG + FIX

Michel Pelletier michel@digicool.com
Tue, 22 Jun 1999 09:43:53 -0400


> -----Original Message-----
> From: Anthony Pfrunder [mailto:s341625@student.uq.edu.au]
> Sent: Tuesday, June 22, 1999 2:41 AM
> To: zope-dev@zope.org
> Subject: [Zope-dev] Win32: BUG + FIX
> 
> 
> 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.
> 

Hey thanks for the patch!  The best way to keep this from being dropped
(right now it is captured only in the list) is to submit a bug report
and the patch to the Collector:

http://www.zope.org/Collector

and we'll get right to it (relativly speaking).

-Michel

> 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
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://www.zope.org/mailman/listinfo/zope-dev
> 
> (For non-developer, user-level issues, use the companion list,
> zope@zope.org, http://www.zope.org/mailman/listinfo/zope )
>