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

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: 668
Merged at revision: 671
Proposed branch: lp:~verterok/ubuntuone-client/fix-621924
Merge into: lp:ubuntuone-client
Diff against target: 107 lines (+70/-2)
2 files modified
tests/syncdaemon/test_dbus.py (+66/-0)
ubuntuone/syncdaemon/dbus_interface.py (+4/-2)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/fix-621924
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Facundo Batista (community) Approve
Review via email: mp+34228@code.launchpad.net

Commit message

Fix dbus interface get_metadata methods to use the realpath.

Description of the change

Fix dbus interface get_metadata methods to use the realpath.

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

Like it! Thanks!

review: Approve
Revision history for this message
John Lenton (chipaca) wrote :

oooh, 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_dbus.py'
2--- tests/syncdaemon/test_dbus.py 2010-08-25 17:45:11 +0000
3+++ tests/syncdaemon/test_dbus.py 2010-08-31 18:11:48 +0000
4@@ -233,6 +233,37 @@
5 error_handler=self.error_handler)
6 return d
7
8+ def test_get_metadata_path_symlink(self):
9+ """Test the FileSystem Object, getting MD by path in a symlink."""
10+ share_path = os.path.join(self.shares_dir, 'share')
11+ self.main.vm.add_share(Share(path=share_path, volume_id='share'))
12+ path = os.path.join(share_path, "foo")
13+ symlink_path = os.path.join(self.shares_dir, "share_symlink")
14+ share_context = self.main.fs._enable_share_write('share',
15+ share_path)
16+ with share_context:
17+ os.makedirs(share_path)
18+ os.symlink(share_path, symlink_path)
19+ self.fs_manager.create(path, "share")
20+ self.fs_manager.set_node_id(path, "node_id")
21+ d = defer.Deferred()
22+ def handler(metadata):
23+ """Reply handler."""
24+ d.callback(metadata)
25+
26+ def callback(result):
27+ """Callback to check the result."""
28+ self.assertEquals(os.path.join(symlink_path, 'foo'), str(result['path']))
29+ self.assertEquals('share', result['share_id'])
30+ self.assertEquals('node_id', result['node_id'])
31+
32+ d.addCallback(callback)
33+ client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME)
34+ client.call_method('get_metadata', os.path.join(symlink_path, 'foo'),
35+ reply_handler=handler,
36+ error_handler=self.error_handler)
37+ return d
38+
39 def test_get_metadata_share_node(self):
40 """Test the FileSystem Object, getting MD by share and node."""
41 share_path = os.path.join(self.shares_dir, 'share')
42@@ -558,6 +589,41 @@
43 error_handler=self.error_handler)
44 return d
45
46+ def test_get_metadata_and_quick_tree_synced_symlink(self):
47+ """Test Status.get_metadata_and_quick_tree_status
48+ without fake data in the AQ."""
49+ share_path = os.path.join(self.shares_dir, 'share')
50+ self.main.vm.add_share(Share(path=share_path, volume_id='share'))
51+ path = os.path.join(share_path, u'ñoño'.encode('utf-8'))
52+ self.fs_manager.create(path, "share")
53+ self.fs_manager.set_node_id(path, "node_id")
54+ symlink_path = os.path.join(self.shares_dir, "share_symlink")
55+ share_context = self.main.fs._enable_share_write('share',
56+ share_path)
57+ with share_context:
58+ os.makedirs(share_path)
59+ os.symlink(share_path, symlink_path)
60+ expected_path = os.path.join(symlink_path, os.path.basename(path))
61+
62+ d = defer.Deferred()
63+ def handler(metadata):
64+ """Reply handler."""
65+ d.callback(metadata)
66+
67+ def callback(result):
68+ """Callback to check the result."""
69+ self.assertEquals(expected_path, unicode(result['path']))
70+ self.assertEquals('share', result['share_id'])
71+ self.assertEquals('node_id', result['node_id'])
72+ self.assertEquals('synced', result['quick_tree_synced'])
73+
74+ d.addCallback(callback)
75+ client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME)
76+ client.call_method('get_metadata_and_quick_tree_synced',
77+ expected_path, reply_handler=handler,
78+ error_handler=self.error_handler)
79+ return d
80+
81 def test_contq_changed(self):
82 """Test the Status.ContentQueueChanged signal."""
83 # prepare the VM so it lies for us
84
85=== modified file 'ubuntuone/syncdaemon/dbus_interface.py'
86--- ubuntuone/syncdaemon/dbus_interface.py 2010-08-25 13:59:42 +0000
87+++ ubuntuone/syncdaemon/dbus_interface.py 2010-08-31 18:11:48 +0000
88@@ -965,7 +965,8 @@
89 def get_metadata(self, path):
90 """Return the metadata (as a dict) for the specified path."""
91 logger.debug('get_metadata by path: %r', path)
92- mdobj = self.fs_manager.get_by_path(path.encode('utf-8'))
93+ real_path = os.path.realpath(path.encode('utf-8'))
94+ mdobj = self.fs_manager.get_by_path(real_path)
95 md_dict = self._mdobj_dict(mdobj)
96 md_dict['path'] = path
97 return md_dict
98@@ -988,7 +989,8 @@
99 the specified path, including the quick subtree status.
100 """
101 logger.debug('get_metadata_and_quick_tree_synced: %r', path)
102- mdobj = self.fs_manager.get_by_path(path.encode('utf-8'))
103+ real_path = os.path.realpath(path.encode('utf-8'))
104+ mdobj = self.fs_manager.get_by_path(real_path)
105 md_dict = self._mdobj_dict(mdobj)
106 md_dict['path'] = path
107 if (self._path_in_queue(path, self.action_queue.meta_queue)

Subscribers

People subscribed via source and target branches