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

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Facundo Batista
Approved revision: 737
Merged at revision: 738
Proposed branch: lp:~verterok/ubuntuone-client/fix-664019-stable-1-4
Merge into: lp:ubuntuone-client/stable-1-4
Diff against target: 107 lines (+39/-32)
2 files modified
tests/syncdaemon/test_vm.py (+35/-31)
ubuntuone/syncdaemon/volume_manager.py (+4/-1)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/fix-664019-stable-1-4
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Lucio Torre (community) Approve
Review via email: mp+38981@code.launchpad.net

Commit message

Trigger a rescan_from_scratch on SV_VOLUME_CREATED in order to get the contents (instead of just the volume).

Description of the change

Correclty handle SV_VOLUME_CREATED event and trigger a rescan_from_scratch on the volume in order to get the contents (instead of just the volume)

To post a comment you must log in.
Revision history for this message
Lucio Torre (lucio.torre) :
review: Approve
Revision history for this message
Facundo Batista (facundo) wrote :

Nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_vm.py'
2--- tests/syncdaemon/test_vm.py 2010-09-28 00:06:20 +0000
3+++ tests/syncdaemon/test_vm.py 2010-10-20 20:41:25 +0000
4@@ -1759,12 +1759,12 @@
5 self.assertTrue(called)
6 self.assertTrue(self.handler.check_warning("missing volume id"))
7
8+ @defer.inlineCallbacks
9 def _test_handle_SV_VOLUME_CREATED(self, auto_subscribe):
10 """Test for handle_SV_VOLUME_CREATED."""
11 user_conf = config.get_user_config()
12 user_conf.set_udf_autosubscribe(auto_subscribe)
13 # start the test
14- d = defer.Deferred()
15 udf_id = uuid.uuid4()
16 udf_volume = volumes.UDFVolume(udf_id, 'udf_uuid', None, 10, u'~/ñoño')
17 share_id = uuid.uuid4()
18@@ -1774,39 +1774,43 @@
19 True, 'View')
20 # initialize the the root
21 self.vm._got_root('root_uuid')
22+
23+ d = defer.Deferred()
24 self._listen_for('VM_UDF_CREATED', d.callback)
25- def check_udf(info):
26- """The udf creation callback"""
27- udf = info[0]
28- self.assertEquals(udf.volume_id, str(udf_id))
29- self.assertIn(str(udf_id), self.vm.udfs)
30- if auto_subscribe:
31- self.assertTrue(udf.subscribed)
32- self.assertTrue(os.path.exists(udf.path))
33- else:
34- self.assertFalse(udf.subscribed)
35- self.assertFalse(os.path.exists(udf.path))
36- # subscribe a new listener
37- d = defer.Deferred()
38- self._listen_for('VM_SHARE_CREATED', d.callback)
39- # fire SV_VOLUME_CREATED with a share
40- with environ('HOME', self.home_dir):
41- self.vm.handle_SV_VOLUME_CREATED(share_volume)
42- return d
43-
44- def check_share(info):
45- """The share creation callback."""
46- share_id = info[0]
47- share = self.vm.get_volume(share_id)
48- self.assertEquals(share.volume_id, str(share_id))
49- self.assertIn(str(share_id), self.vm.shares)
50-
51- d.addCallback(check_udf)
52- d.addCallback(check_share)
53- # use a custom home
54+ rescan_cb = defer.Deferred()
55+ self.patch(self.main.action_q, 'rescan_from_scratch', rescan_cb.callback)
56+
57 with environ('HOME', self.home_dir):
58 self.vm.handle_SV_VOLUME_CREATED(udf_volume)
59- return d
60+ info = yield d
61+ udf = info[0]
62+ self.assertEquals(udf.volume_id, str(udf_id))
63+ self.assertIn(str(udf_id), self.vm.udfs)
64+ if auto_subscribe:
65+ self.assertTrue(udf.subscribed)
66+ self.assertTrue(os.path.exists(udf.path))
67+ # check that rescan_from_scratch is called
68+ vol_id = yield rescan_cb
69+ self.assertEqual(vol_id, udf.volume_id)
70+ else:
71+ self.assertFalse(udf.subscribed)
72+ self.assertFalse(os.path.exists(udf.path))
73+ # subscribe a new listener
74+ d = defer.Deferred()
75+ self._listen_for('VM_SHARE_CREATED', d.callback)
76+ rescan_cb = defer.Deferred()
77+ self.patch(self.main.action_q, 'rescan_from_scratch', rescan_cb.callback)
78+ # fire SV_VOLUME_CREATED with a share
79+ with environ('HOME', self.home_dir):
80+ self.vm.handle_SV_VOLUME_CREATED(share_volume)
81+ info = yield d
82+ share_id = info[0]
83+ share = self.vm.get_volume(share_id)
84+ self.assertEquals(share.volume_id, str(share_id))
85+ self.assertIn(str(share_id), self.vm.shares)
86+ # check that rescan_from_scratch is called
87+ vol_id = yield rescan_cb
88+ self.assertEqual(vol_id, share.volume_id)
89
90 def test_handle_SV_VOLUME_CREATED_subscribe(self):
91 """Test SV_VOLUME_CREATED with udf auto_subscribe """
92
93=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
94--- ubuntuone/syncdaemon/volume_manager.py 2010-09-28 00:06:20 +0000
95+++ ubuntuone/syncdaemon/volume_manager.py 2010-10-20 20:41:25 +0000
96@@ -1235,7 +1235,10 @@
97
98 def handle_SV_VOLUME_CREATED(self, volume):
99 """Handle SV_VOLUME_CREATED event."""
100- self._handle_new_volume(volume)
101+ vol = self._handle_new_volume(volume)
102+ if vol and vol.active:
103+ self.m.action_q.rescan_from_scratch(vol.volume_id)
104+
105
106 def handle_SV_VOLUME_DELETED(self, volume_id):
107 """Handle SV_VOLUME_DELETED event."""

Subscribers

People subscribed via source and target branches