Merge lp:~facundo/ubuntuone-client/root-always-subscribed into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 1129
Merged at revision: 1130
Proposed branch: lp:~facundo/ubuntuone-client/root-always-subscribed
Merge into: lp:ubuntuone-client
Diff against target: 38 lines (+17/-0)
2 files modified
tests/syncdaemon/test_vm.py (+15/-0)
ubuntuone/syncdaemon/volume_manager.py (+2/-0)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/root-always-subscribed
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Ian Wilkinson (community) Approve
Review via email: mp+74265@code.launchpad.net

Commit message

Root is always subscribed (LP: #842839)

Description of the change

Root is always subscribed.

Added a class attribute 'subscribed' in True to Root, as we're now checking all volumes for subscription, and even as today Root has the subscribed attribute set in __init__ to True, old Root instances are pickled without it.

Other way to fix this would have been triggered a VolumeManager metadata upgrade, but the way I did it here is way safer (specially when verterok is on vacation).

Test included.

To post a comment you must log in.
Revision history for this message
Ian Wilkinson (theiw) wrote :

+1

review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Nice fix

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 2011-08-12 15:11:36 +0000
3+++ tests/syncdaemon/test_vm.py 2011-09-06 18:49:23 +0000
4@@ -1305,6 +1305,21 @@
5 'watch for %r should be present.' % path)
6 self.vm._remove_watch(path)
7
8+ def test_support_old_root_without_subscribed(self):
9+ """Old Roots were pickled without subscribed attribute."""
10+ # generate the situation
11+ old_attr = Root.subscribed
12+ del Root.subscribed
13+ root = Root(node_id='root_node_id')
14+ del root.subscribed
15+ assert not hasattr(root, 'subscribed')
16+ serialized = cPickle.dumps(root)
17+ Root.subscribed = old_attr
18+
19+ # unserialize
20+ new_root = cPickle.loads(serialized)
21+ self.assertTrue(new_root.subscribed)
22+
23
24 class VolumeManagerUnicodeTests(BaseVolumeManagerTests):
25 """Tests for Volume Manager unicode capabilities."""
26
27=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
28--- ubuntuone/syncdaemon/volume_manager.py 2011-08-25 18:27:25 +0000
29+++ ubuntuone/syncdaemon/volume_manager.py 2011-09-06 18:49:23 +0000
30@@ -267,6 +267,8 @@
31 class Root(Volume):
32 """A volume representing the root."""
33
34+ subscribed = True
35+
36 def __init__(self, volume_id=request.ROOT, node_id=None, path=None,
37 free_bytes=None, generation=None):
38 """Create the Root."""

Subscribers

People subscribed via source and target branches