Merge lp:~verterok/ubuntuone-client/fix-692496-stable-1-4 into lp:ubuntuone-client/stable-1-4

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: dobey
Approved revision: 743
Merged at revision: 745
Proposed branch: lp:~verterok/ubuntuone-client/fix-692496-stable-1-4
Merge into: lp:ubuntuone-client/stable-1-4
Diff against target: 136 lines (+21/-40)
5 files modified
tests/syncdaemon/test_fsm.py (+9/-21)
tests/syncdaemon/test_localrescan.py (+10/-1)
ubuntuone/syncdaemon/filesystem_manager.py (+0/-8)
ubuntuone/syncdaemon/local_rescan.py (+2/-0)
ubuntuone/syncdaemon/sync.py (+0/-10)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/fix-692496-stable-1-4
Reviewer Review Type Date Requested Status
dobey (community) Approve
Facundo Batista (community) Approve
Review via email: mp+44273@code.launchpad.net

Commit message

Fix local rescan to handle the case of the stat in metadata being None.

Description of the change

This branch fix local rescan to handle the case of the stat in metadata being None, also remove the unused refresh_stat methods from fsm and sync.

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) wrote :

+1

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/syncdaemon/test_fsm.py'
--- tests/syncdaemon/test_fsm.py 2010-10-25 19:51:17 +0000
+++ tests/syncdaemon/test_fsm.py 2010-12-20 20:08:44 +0000
@@ -121,6 +121,13 @@
121 mdobj = self.fsm.get_by_mdid(mdid)121 mdobj = self.fsm.get_by_mdid(mdid)
122 return mdobj122 return mdobj
123123
124 def refresh_stat(self, fsm, path):
125 """Refresh the stat of a md object."""
126 mdid = fsm._idx_path[path]
127 mdobj = fsm.fs[mdid]
128 mdobj["stat"] = os.lstat(path)
129 fsm.fs[mdid] = mdobj
130
124131
125class StartupTests(unittest.TestCase):132class StartupTests(unittest.TestCase):
126 """Test the basic startup behaviour."""133 """Test the basic startup behaviour."""
@@ -888,8 +895,8 @@
888 fsm.set_node_id(path2, "uuid2")895 fsm.set_node_id(path2, "uuid2")
889 self.assertTrue(os.path.exists(fsm.fs.key_file(mdid1+'.old')))896 self.assertTrue(os.path.exists(fsm.fs.key_file(mdid1+'.old')))
890 self.assertTrue(os.path.exists(fsm.fs.key_file(mdid2+'.old')))897 self.assertTrue(os.path.exists(fsm.fs.key_file(mdid2+'.old')))
891 fsm.refresh_stat(path1)898 self.refresh_stat(fsm, path1)
892 fsm.refresh_stat(path2)899 self.refresh_stat(fsm, path2)
893 self.assertTrue(os.path.exists(self.fsm.fs.key_file(mdid1+'.old')))900 self.assertTrue(os.path.exists(self.fsm.fs.key_file(mdid1+'.old')))
894 self.assertTrue(os.path.exists(self.fsm.fs.key_file(mdid2+'.old')))901 self.assertTrue(os.path.exists(self.fsm.fs.key_file(mdid2+'.old')))
895 # break the second node on purpose but with an invalid pickle902 # break the second node on purpose but with an invalid pickle
@@ -1391,25 +1398,6 @@
1391 mdobj = self.create_node("thisdir")1398 mdobj = self.create_node("thisdir")
1392 self.assertEqual(mdobj.stat, os.stat(path))1399 self.assertEqual(mdobj.stat, os.stat(path))
13931400
1394 def test_refresh(self):
1395 """Test that refresh_stat works."""
1396 path = os.path.join(self.share.path, "thisfile")
1397 open(path, "w").close()
1398 mdobj = self.create_node("thisfile")
1399 mdid = mdobj.mdid
1400 oldstat = os.stat(path)
1401 self.assertEqual(mdobj.stat, oldstat)
1402
1403 # touch the file, it's not automagically updated
1404 open(path, "w").close()
1405 mdobj = self.fsm.get_by_mdid(mdid)
1406 self.assertEqual(mdobj.stat, oldstat)
1407
1408 # it's updated when asked
1409 self.fsm.refresh_stat(path)
1410 mdobj = self.fsm.get_by_mdid(mdid)
1411 self.assertEqual(mdobj.stat, os.stat(path))
1412
1413 def test_commit_partial(self):1401 def test_commit_partial(self):
1414 """Test that it's updated in the commit."""1402 """Test that it's updated in the commit."""
1415 path = os.path.join(self.share.path, "thisfile")1403 path = os.path.join(self.share.path, "thisfile")
14161404
=== modified file 'tests/syncdaemon/test_localrescan.py'
--- tests/syncdaemon/test_localrescan.py 2010-09-16 14:09:12 +0000
+++ tests/syncdaemon/test_localrescan.py 2010-12-20 20:08:44 +0000
@@ -1586,7 +1586,9 @@
1586 # start a put file, and assume we got interrupted (no server hash)1586 # start a put file, and assume we got interrupted (no server hash)
1587 pathhash = self._hash(path)1587 pathhash = self._hash(path)
1588 self.fsm.set_by_mdid(mdid, local_hash=pathhash, crc32='foo')1588 self.fsm.set_by_mdid(mdid, local_hash=pathhash, crc32='foo')
1589 self.fsm.refresh_stat(path)1589 mdobj = self.fsm.fs[mdid]
1590 mdobj["stat"] = os.lstat(path)
1591 self.fsm.fs[mdid] = mdobj
15901592
1591 def check(_):1593 def check(_):
1592 """Compare predictable args, and check fh factory."""1594 """Compare predictable args, and check fh factory."""
@@ -2070,6 +2072,13 @@
2070 self.startTest(check)2072 self.startTest(check)
2071 return self.deferred2073 return self.deferred
20722074
2075 def test_check_stat_None(self):
2076 """Test check_stat with oldstat = None."""
2077 # create the file in metadata
2078 path = os.path.join(self.share.path, "a_file")
2079 self.fsm.create(path, self.share.volume_id, is_dir=False)
2080 self.assertTrue(self.lr.check_stat(path, None))
2081
20732082
2074class RootBadStateTests(TwistedBase):2083class RootBadStateTests(TwistedBase):
2075 """Test what happens with volume roots left in a bad state last time."""2084 """Test what happens with volume roots left in a bad state last time."""
20762085
=== modified file 'ubuntuone/syncdaemon/filesystem_manager.py'
--- ubuntuone/syncdaemon/filesystem_manager.py 2010-10-25 19:51:17 +0000
+++ ubuntuone/syncdaemon/filesystem_manager.py 2010-12-20 20:08:44 +0000
@@ -642,14 +642,6 @@
642 mdid = self._idx_node_id[(share_id, node_id)]642 mdid = self._idx_node_id[(share_id, node_id)]
643 self.set_by_mdid(mdid, **kwargs)643 self.set_by_mdid(mdid, **kwargs)
644644
645 def refresh_stat(self, path):
646 """Refresh the stat of a md object."""
647 log_debug("refresh stat to path=%r", path)
648 mdid = self._idx_path[path]
649 mdobj = self.fs[mdid]
650 mdobj["stat"] = get_stat(path)
651 self.fs[mdid] = mdobj
652
653 def move_file(self, new_share_id, path_from, path_to):645 def move_file(self, new_share_id, path_from, path_to):
654 """Move a file/dir from one point to the other."""646 """Move a file/dir from one point to the other."""
655 path_from = os.path.normpath(path_from)647 path_from = os.path.normpath(path_from)
656648
=== modified file 'ubuntuone/syncdaemon/local_rescan.py'
--- ubuntuone/syncdaemon/local_rescan.py 2010-09-16 14:09:12 +0000
+++ ubuntuone/syncdaemon/local_rescan.py 2010-12-20 20:08:44 +0000
@@ -359,6 +359,8 @@
359 - st_size: it changed in size, surely different content359 - st_size: it changed in size, surely different content
360 - st_mtime: the content could be different even having the same size360 - st_mtime: the content could be different even having the same size
361 """361 """
362 if oldstat is None:
363 return True
362 newstat = os.stat(fullname)364 newstat = os.stat(fullname)
363 different = (newstat.st_ino != oldstat.st_ino or365 different = (newstat.st_ino != oldstat.st_ino or
364 newstat.st_size != oldstat.st_size or366 newstat.st_size != oldstat.st_size or
365367
=== modified file 'ubuntuone/syncdaemon/sync.py'
--- ubuntuone/syncdaemon/sync.py 2010-11-09 12:50:57 +0000
+++ ubuntuone/syncdaemon/sync.py 2010-12-20 20:08:44 +0000
@@ -200,16 +200,6 @@
200 """Move file to conflict."""200 """Move file to conflict."""
201 self.fs.move_to_conflict(self.get_mdid())201 self.fs.move_to_conflict(self.get_mdid())
202202
203 def refresh_stat(self):
204 """Refresh the stat."""
205 path = self["path"]
206 # pylint: disable-msg=W0704
207 try:
208 self.fs.refresh_stat(path)
209 except OSError:
210 # no file to stat, nothing to do
211 pass
212
213 def safe_get(self, key, default='^_^'):203 def safe_get(self, key, default='^_^'):
214 """Safe version of self.get, to be used in the FileLogger."""204 """Safe version of self.get, to be used in the FileLogger."""
215 # catch all errors as we are here to help logging205 # catch all errors as we are here to help logging

Subscribers

People subscribed via source and target branches