Merge lp:~verterok/ubuntuone-client/really-fix-share-changed-handling into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Facundo Batista
Approved revision: 140
Merged at revision: not available
Proposed branch: lp:~verterok/ubuntuone-client/really-fix-share-changed-handling
Merge into: lp:ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/really-fix-share-changed-handling
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Rick McBride (community) Approve
Review via email: mp+10061@code.launchpad.net

Commit message

fix VolumeManager to correctly handle UUID's as share id

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

This branch fix VolumeManager to correctly handle UUID's (previously assumed the share_id was always a str)

Revision history for this message
Rick McBride (rmcbride) wrote :

Very nice.

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

Looks fine.

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 2009-08-11 14:33:43 +0000
3+++ tests/syncdaemon/test_vm.py 2009-08-12 19:49:30 +0000
4@@ -120,7 +120,8 @@
5
6 def test_handle_AQ_SHARES_LIST(self):
7 """ test the handling of the AQ_SHARE_LIST event. """
8- share_response = ShareResponse.from_params('share_id', 'to_me',
9+ share_id = uuid.uuid4()
10+ share_response = ShareResponse.from_params(share_id, 'to_me',
11 'fake_share_uuid',
12 'fake_share', 'username',
13 'visible_username', 'yes',
14@@ -132,14 +133,17 @@
15 self.vm.handle_AQ_SHARES_LIST(response)
16 self.assertEquals(2, len(self.vm.shares)) # the new shares and root
17 # check that the share is in the shares dict
18- self.assertTrue('share_id' in self.vm.shares)
19- share = self.vm.shares['share_id']
20+ self.assertTrue(str(share_id) in self.vm.shares)
21+ share = self.vm.shares[str(share_id)]
22 self.assertEquals('fake_share', share.name)
23 self.assertEquals('fake_share_uuid', share.subtree)
24
25+
26+
27 def test_handle_SV_SHARE_CHANGED(self):
28 """ test the handling of the AQ_SHARE_LIST event. """
29- share_holder = NotifyShareHolder.from_params('share_id', None,
30+ share_id = uuid.uuid4()
31+ share_holder = NotifyShareHolder.from_params(share_id, None,
32 'fake_share',
33 'test_username',
34 'visible_name', 'Modify')
35@@ -147,11 +151,11 @@
36 self.vm.on_server_root('root_uuid')
37 # create a share
38 share_path = os.path.join(self.shares_dir, share_holder.share_name)
39- share = Share(share_path, share_id=share_holder.share_id,
40+ share = Share(share_path, share_id=str(share_holder.share_id),
41 access_level='View')
42 self.vm.add_share(share)
43 self.vm.handle_SV_SHARE_CHANGED(message='changed', info=share_holder)
44- self.assertEquals('Modify', self.vm.shares['share_id'].access_level)
45+ self.assertEquals('Modify', self.vm.shares[str(share_id)].access_level)
46 self.vm.handle_SV_SHARE_CHANGED('deleted', share_holder)
47 self.assertNotIn('share_id', self.vm.shares)
48
49@@ -167,12 +171,14 @@
50
51 def test_handle_AQ_SHARES_LIST_shared(self):
52 """test the handling of the AQ_SHARE_LIST event, with a shared dir."""
53- share_response = ShareResponse.from_params('share_id', 'to_me',
54+ share_id = uuid.uuid4()
55+ share_response = ShareResponse.from_params(share_id, 'to_me',
56 'fake_share_uuid',
57 'fake_share', 'username',
58 'visible_username', 'yes',
59 'View')
60- shared_response = ShareResponse.from_params('shared_id', 'from_me',
61+ shared_id = uuid.uuid4()
62+ shared_response = ShareResponse.from_params(shared_id, 'from_me',
63 'shared_uuid',
64 'fake_shared', 'myname',
65 'my_visible_name', 'yes',
66@@ -187,7 +193,7 @@
67 self.vm.handle_AQ_SHARES_LIST(response)
68 self.assertEquals(2, len(self.vm.shares)) # the new shares and root
69 self.assertEquals(1, len(self.vm.shared)) # the new shares and root
70- shared = self.vm.shared['shared_id']
71+ shared = self.vm.shared[str(shared_id)]
72 self.assertEquals('fake_shared', shared.name)
73 # check that the uuid is stored in fs
74 mdobj = self.main.fs.get_by_path(shared.path)
75
76=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
77--- ubuntuone/syncdaemon/volume_manager.py 2009-08-11 14:33:43 +0000
78+++ ubuntuone/syncdaemon/volume_manager.py 2009-08-12 20:13:15 +0000
79@@ -246,7 +246,7 @@
80 def handle_SV_SHARE_CHANGED(self, message, info):
81 """ handle SV_SHARE_CHANGED event """
82 if message == 'changed':
83- if info.share_id not in self.shares:
84+ if str(info.share_id) not in self.shares:
85 self.log.debug("New share notification, share_id: %s",
86 info.share_id)
87 dir_name = self._build_dirname(info.share_name,
88@@ -259,7 +259,7 @@
89 self.share_changed(info)
90 elif message == 'deleted':
91 self.log.debug('share deleted! %s', info.share_id)
92- self.share_deleted(info.share_id)
93+ self.share_deleted(str(info.share_id))
94
95 def handle_AQ_CREATE_SHARE_OK(self, share_id, marker):
96 """ handle AQ_CREATE_SHARE_OK event. """
97@@ -334,14 +334,15 @@
98
99 def share_changed(self, share_holder):
100 """ process the share changed event """
101- share = self.shares.get(share_holder.share_id, None)
102+ # the holder id is a uuid, use the str
103+ share = self.shares.get(str(share_holder.share_id), None)
104 if share is None:
105 # we don't have this share, ignore it
106 self.log.warning("Got a share changed notification (%r), "
107 "but don't have the share", share_holder.share_id)
108 else:
109 share.access_level = share_holder.access_level
110- self.shares[share_holder.share_id] = share
111+ self.shares[share.id] = share
112
113 def _create_share_dir(self, share):
114 """ Creates the share root dir, and set the permissions. """

Subscribers

People subscribed via source and target branches