conduit r1822 - in trunk: . conduit/datatypes test/python-tests
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1822 - in trunk: . conduit/datatypes test/python-tests
- Date: Tue, 20 Jan 2009 03:50:13 +0000 (UTC)
Author: jstowers
Date: Tue Jan 20 03:50:12 2009
New Revision: 1822
URL: http://svn.gnome.org/viewvc/conduit?rev=1822&view=rev
Log:
2009-01-20 John Stowers <john stowers gmail com>
* conduit/datatypes/File.py: Include the filesize and
mtime when calculating its hash. Fixes #568362 (Brian Teague)
* test/python-tests/TestCoreFile.py: Test for the above
Modified:
trunk/ChangeLog
trunk/conduit/datatypes/File.py
trunk/test/python-tests/TestCoreFile.py
Modified: trunk/conduit/datatypes/File.py
==============================================================================
--- trunk/conduit/datatypes/File.py (original)
+++ trunk/conduit/datatypes/File.py Tue Jan 20 03:50:12 2009
@@ -315,9 +315,9 @@
def get_hash(self):
# Join the tags into a string to be hashed so the object is updated if
# they change.
- tagstr = "".join(self.get_tags())
- #FIXME: self.get_size() does not seem reliable
+ tagstr = "%s%s%s" % (self.get_mtime(),self.get_size(),"".join(self.get_tags()))
return str(hash(tagstr))
+
def get_filename(self):
"""
Modified: trunk/test/python-tests/TestCoreFile.py
==============================================================================
--- trunk/test/python-tests/TestCoreFile.py (original)
+++ trunk/test/python-tests/TestCoreFile.py Tue Jan 20 03:50:12 2009
@@ -53,10 +53,25 @@
contents = temp.get_contents_as_text()
ok("Base: wrote contents again", contents == "456")
+ # write a random amount to the temp file
+
tempsize = random.randint(100, 200)
contents = "a"*tempsize
temp.set_contents_as_text(contents)
ok( "Base: file size is accurate", temp.get_size() == tempsize )
+ old_mtime = temp.get_mtime();
+ old_hash = temp.get_hash();
+
+ # now, add some more
+ tempsize = random.randint(100, 200)
+ contents += "b"*tempsize
+ temp.set_contents_as_text(contents)
+ ok("Base: Check if appending to a file changes its hash", temp.get_hash() != old_hash)
+
+ # reset the mtime, and make sure the hash is still different
+ temp.set_mtime( old_mtime )
+ ok( "Base: Check if reseting a file's mtime is successful", temp.get_mtime() == old_mtime )
+ ok( "Base: Check that the hash is still different, even with the same mtime.", temp.get_hash() != old_hash )
remUri = get_external_resources('folder')['removable-volume']
rf = File.File(remUri,implName=impl)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]