[Zodb-checkins] CVS: Packages/bsddb3Storage - CommitLog.py:1.6
barry@digicool.com
barry@digicool.com
Mon, 23 Apr 2001 23:32:51 -0400 (EDT)
Update of /cvs-repository/Packages/bsddb3Storage
In directory korak:/tmp/cvs-serv5171
Modified Files:
CommitLog.py
Log Message:
CommitLog.__init__(): Use an unlink flag to record what the behavior
should be on close. By default, we unlink the file unless we were
passed a file-like object, in which case we don't unlink by default
(because the client owns the file).
close(): Only close the file if the file isn't already closed. Only
unlink if the default unlink flag is true, or we're explicitly told to
unlink via the argument. This should fix the logfile turd problem.
--- Updated File CommitLog.py in package Packages/bsddb3Storage --
--- CommitLog.py 2001/04/13 19:04:24 1.5
+++ CommitLog.py 2001/04/24 03:32:50 1.6
@@ -121,6 +121,7 @@
# BAW: is our filename unique enough? Are we opening it up with too
# much or too little security?
+ self._unlink = 1
if file is None:
# Create the file from scratch. We know the file has to be in the
# init state, so just go ahead and write the appropriate header.
@@ -161,6 +162,7 @@
# log. Read the file's header and initialize our state from it.
self._fp = file
self._readhead()
+ self._unlink = 0
def get_filename(self):
return self._fp.name
@@ -266,14 +268,16 @@
def next(self):
raise NotImplementedError
- def close(self, unlink=0):
+ def close(self, unlink=1):
"""Close the file.
If unlink is true, delete the underlying file object too.
"""
- self._fp.close()
- if unlink:
- os.unlink(self._fp.name)
+ if self._fp:
+ self._fp.close()
+ if unlink or self._unlink:
+ os.unlink(self._fp.name)
+ self._fp = None
def __del__(self):
# Unsafe, and file preserving close
--- Updated File CommitLog.py in package Packages/bsddb3Storage --
--- CommitLog.py 2001/04/13 19:04:24 1.5
+++ CommitLog.py 2001/04/24 03:32:50 1.6
@@ -121,6 +121,7 @@
# BAW: is our filename unique enough? Are we opening it up with too
# much or too little security?
+ self._unlink = 1
if file is None:
# Create the file from scratch. We know the file has to be in the
# init state, so just go ahead and write the appropriate header.
@@ -161,6 +162,7 @@
# log. Read the file's header and initialize our state from it.
self._fp = file
self._readhead()
+ self._unlink = 0
def get_filename(self):
return self._fp.name
@@ -266,14 +268,16 @@
def next(self):
raise NotImplementedError
- def close(self, unlink=0):
+ def close(self, unlink=1):
"""Close the file.
If unlink is true, delete the underlying file object too.
"""
- self._fp.close()
- if unlink:
- os.unlink(self._fp.name)
+ if self._fp:
+ self._fp.close()
+ if unlink or self._unlink:
+ os.unlink(self._fp.name)
+ self._fp = None
def __del__(self):
# Unsafe, and file preserving close