[Pkg-bazaar-commits] ./bzr/unstable r130: - fixup checks on retrieved files to cope with compression,
mbp at sourcefrog.net
mbp at sourcefrog.net
Fri Apr 10 07:51:12 UTC 2009
------------------------------------------------------------
revno: 130
committer: mbp at sourcefrog.net
timestamp: Tue 2005-03-29 11:26:19 +1000
message:
- fixup checks on retrieved files to cope with compression,
and have less checks now there's a check command again
- move code to destroy stores into the ScratchStore subclass
modified:
bzrlib/store.py
bzrlib/tree.py
-------------- next part --------------
=== modified file 'bzrlib/store.py'
--- a/bzrlib/store.py 2005-03-29 01:16:16 +0000
+++ b/bzrlib/store.py 2005-03-29 01:26:19 +0000
@@ -155,23 +155,6 @@
return count, total
- def delete_all(self):
- for fileid in self:
- self.delete(fileid)
-
- def delete(self, fileid):
- """Remove nominated store entry.
-
- Most stores will be add-only."""
- filename = self._path(fileid)
- ## osutils.make_writable(filename)
- ## TODO: handle gzip
- os.remove(filename)
-
- def destroy(self):
- """Remove store; only allowed if it is empty."""
- os.rmdir(self._basedir)
- mutter("%r destroyed" % self)
@@ -185,5 +168,7 @@
ImmutableStore.__init__(self, tempfile.mkdtemp())
def __del__(self):
- self.delete_all()
- self.destroy()
+ for f in os.listdir(self._basedir):
+ os.remove(os.path.join(self._basedir, f))
+ os.rmdir(self._basedir)
+ mutter("%r destroyed" % self)
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2005-03-27 09:50:34 +0000
+++ b/bzrlib/tree.py 2005-03-29 01:26:19 +0000
@@ -23,7 +23,7 @@
from inventory import Inventory
from trace import mutter, note
from osutils import pumpfile, compare_files, filesize, quotefn, sha_file, \
- joinpath, splitpath, appendpath, isdir, isfile, file_kind
+ joinpath, splitpath, appendpath, isdir, isfile, file_kind, fingerprint_file
from errors import bailout
import branch
from stat import S_ISREG, S_ISDIR, ST_MODE, ST_SIZE
@@ -73,21 +73,20 @@
doc="Inventory of this Tree")
def _check_retrieved(self, ie, f):
- # TODO: Test this check by damaging the store?
+ fp = fingerprint_file(f)
+ f.seek(0)
+
if ie.text_size is not None:
- fs = filesize(f)
- if fs != ie.text_size:
+ if fs != fp['size']:
bailout("mismatched size for file %r in %r" % (ie.file_id, self._store),
["inventory expects %d bytes" % ie.text_size,
- "file is actually %d bytes" % fs,
+ "file is actually %d bytes" % fp['size'],
"store is probably damaged/corrupt"])
- f_hash = sha_file(f)
- f.seek(0)
- if ie.text_sha1 != f_hash:
+ if ie.text_sha1 != fp['sha1']:
bailout("wrong SHA-1 for file %r in %r" % (ie.file_id, self._store),
["inventory expects %s" % ie.text_sha1,
- "file is actually %s" % f_hash,
+ "file is actually %s" % fp['sha1'],
"store is probably damaged/corrupt"])
@@ -315,10 +314,7 @@
ie = self._inventory[file_id]
f = self._store[ie.text_id]
mutter(" get fileid{%s} from %r" % (file_id, self))
- fs = filesize(f)
- if ie.text_size is None:
- note("warning: no text size recorded on %r" % ie)
- self._check_retrieved(ie, f)
+ ## self._check_retrieved(ie, f)
return f
def get_file_size(self, file_id):
More information about the Pkg-bazaar-commits
mailing list