Merge lp:~verterok/ubuntuone-client/fix-684408 into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Natalia Bidart
Approved revision: 759
Merged at revision: 759
Proposed branch: lp:~verterok/ubuntuone-client/fix-684408
Merge into: lp:ubuntuone-client
Diff against target: 79 lines (+26/-9)
2 files modified
tests/syncdaemon/test_vm.py (+24/-3)
ubuntuone/syncdaemon/volume_manager.py (+2/-6)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/fix-684408
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Facundo Batista (community) Approve
Review via email: mp+42562@code.launchpad.net

Commit message

Fix VM to correctly handle volumes and don't delete them.

Description of the change

Fix VM to correctly handle volumes.

To post a comment you must log in.
759. By Guillermo Gonzalez

fix comments

Revision history for this message
Facundo Batista (facundo) wrote :

Nice, thanks!

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Code looks great, and branch works perfectly. Tested carefully with Facundo's assistance.

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-12-01 20:10:29 +0000
3+++ tests/syncdaemon/test_vm.py 2010-12-03 13:17:32 +0000
4@@ -1220,7 +1220,8 @@
5 self.assertEqual(os.path.join(self.home_dir, 'UDF'), udf.path)
6 else: # udf was not added to VM
7 self.assertEqual(2, len(list(self.vm.get_volumes())))
8- self.assertEqual(0, len(self.vm.udfs)) # the new udf
9+ self.assertEqual(1, len(self.vm.udfs)) # the new udf
10+ self.assertFalse(self.vm.udfs.values()[0].active)
11
12 self.assertEqual(2, len(self.vm.shares)) # the share and the root
13 # check that the share is in the shares dict
14@@ -1244,9 +1245,10 @@
15 # root, share and udf
16 self.assertEqual(1, len(self.vm.udfs)) # one udf
17 self.assertEqual(3, len(list(self.vm.get_volumes())))
18- else: # udf was not added to VM
19+ else: # udf was added to VM, but isn't active
20 self.assertEqual(2, len(list(self.vm.get_volumes())))
21- self.assertEqual(0, len(self.vm.udfs)) # the new udf
22+ self.assertEqual(1, len(self.vm.udfs)) # the new udf
23+ self.assertFalse(self.vm.udfs.values()[0].active)
24
25 @defer.inlineCallbacks
26 def test_handle_AQ_LIST_VOLUMES_accepted_share_with_autosubscribe(self):
27@@ -2573,6 +2575,25 @@
28 self.assertEquals(udf.path, mdobj.path)
29
30 @defer.inlineCallbacks
31+ def test_volumes_rescan_cb_active_udf(self):
32+ """Test _volumes_rescan_cb with an active UDF and no-autosubscribe."""
33+ udf_id = uuid.uuid4()
34+ udf, udf_volume = self._create_udf(udf_id, uuid.uuid4(), '~/UDF')
35+ udf_volume.generation = 10
36+ root_id = uuid.uuid4()
37+ root_volume = volumes.RootVolume(root_id, 1, 500)
38+ response = [udf_volume, root_volume]
39+ yield self.vm.add_udf(udf)
40+ # subscribe the udf
41+ yield self.vm.subscribe_udf(udf.volume_id)
42+ d = defer.Deferred()
43+ self._listen_for('SV_VOLUME_NEW_GENERATION', d.callback, 1)
44+ with environ('HOME', self.home_dir):
45+ shares, udfs = self.vm._volumes_rescan_cb(response)
46+ self.assertIn(udf.volume_id, udfs)
47+ yield d
48+
49+ @defer.inlineCallbacks
50 def test_update_generation(self):
51 """Test for the update_generation method."""
52 share_id = uuid.uuid4()
53
54=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
55--- ubuntuone/syncdaemon/volume_manager.py 2010-12-01 20:10:29 +0000
56+++ ubuntuone/syncdaemon/volume_manager.py 2010-12-03 13:17:32 +0000
57@@ -508,11 +508,9 @@
58 except VolumeDoesNotExist:
59 # a new volume!
60 self.log.debug('New volume! id: %r', volume_id)
61+ # if this is a UDF, _handle_new_volume will do a local
62+ # rescan of the volume and activate it after that.
63 volume = self._handle_new_volume(new_volume)
64- # if this new volume is a UDF, it will be skipped as
65- # isn't active until the local rescan finish.
66- # It's safe to skip it as a rescan_from_scratch is
67- # executed after the local rescan.
68 finally:
69 current_generation = volume.generation
70
71@@ -536,8 +534,6 @@
72 events.append(('VM_SHARE_CREATED',
73 dict(share_id=volume.volume_id)))
74 elif isinstance(new_volume, UDFVolume):
75- if not autosubscribe:
76- continue
77 # check if the fsm node exists, and create it if not
78 self._create_fsm_object(volume.path, volume.id, volume.node_id)
79 udfs.append(volume_id)

Subscribers

People subscribed via source and target branches