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
=== modified file 'tests/syncdaemon/test_dbus.py'
--- tests/syncdaemon/test_dbus.py 2010-08-25 17:45:11 +0000
+++ tests/syncdaemon/test_dbus.py 2010-08-31 18:11:48 +0000
@@ -233,6 +233,37 @@
233 error_handler=self.error_handler)233 error_handler=self.error_handler)
234 return d234 return d
235235
236 def test_get_metadata_path_symlink(self):
237 """Test the FileSystem Object, getting MD by path in a symlink."""
238 share_path = os.path.join(self.shares_dir, 'share')
239 self.main.vm.add_share(Share(path=share_path, volume_id='share'))
240 path = os.path.join(share_path, "foo")
241 symlink_path = os.path.join(self.shares_dir, "share_symlink")
242 share_context = self.main.fs._enable_share_write('share',
243 share_path)
244 with share_context:
245 os.makedirs(share_path)
246 os.symlink(share_path, symlink_path)
247 self.fs_manager.create(path, "share")
248 self.fs_manager.set_node_id(path, "node_id")
249 d = defer.Deferred()
250 def handler(metadata):
251 """Reply handler."""
252 d.callback(metadata)
253
254 def callback(result):
255 """Callback to check the result."""
256 self.assertEquals(os.path.join(symlink_path, 'foo'), str(result['path']))
257 self.assertEquals('share', result['share_id'])
258 self.assertEquals('node_id', result['node_id'])
259
260 d.addCallback(callback)
261 client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME)
262 client.call_method('get_metadata', os.path.join(symlink_path, 'foo'),
263 reply_handler=handler,
264 error_handler=self.error_handler)
265 return d
266
236 def test_get_metadata_share_node(self):267 def test_get_metadata_share_node(self):
237 """Test the FileSystem Object, getting MD by share and node."""268 """Test the FileSystem Object, getting MD by share and node."""
238 share_path = os.path.join(self.shares_dir, 'share')269 share_path = os.path.join(self.shares_dir, 'share')
@@ -558,6 +589,41 @@
558 error_handler=self.error_handler)589 error_handler=self.error_handler)
559 return d590 return d
560591
592 def test_get_metadata_and_quick_tree_synced_symlink(self):
593 """Test Status.get_metadata_and_quick_tree_status
594 without fake data in the AQ."""
595 share_path = os.path.join(self.shares_dir, 'share')
596 self.main.vm.add_share(Share(path=share_path, volume_id='share'))
597 path = os.path.join(share_path, u'ñoño'.encode('utf-8'))
598 self.fs_manager.create(path, "share")
599 self.fs_manager.set_node_id(path, "node_id")
600 symlink_path = os.path.join(self.shares_dir, "share_symlink")
601 share_context = self.main.fs._enable_share_write('share',
602 share_path)
603 with share_context:
604 os.makedirs(share_path)
605 os.symlink(share_path, symlink_path)
606 expected_path = os.path.join(symlink_path, os.path.basename(path))
607
608 d = defer.Deferred()
609 def handler(metadata):
610 """Reply handler."""
611 d.callback(metadata)
612
613 def callback(result):
614 """Callback to check the result."""
615 self.assertEquals(expected_path, unicode(result['path']))
616 self.assertEquals('share', result['share_id'])
617 self.assertEquals('node_id', result['node_id'])
618 self.assertEquals('synced', result['quick_tree_synced'])
619
620 d.addCallback(callback)
621 client = DBusClient(self.bus, '/filesystem', DBUS_IFACE_FS_NAME)
622 client.call_method('get_metadata_and_quick_tree_synced',
623 expected_path, reply_handler=handler,
624 error_handler=self.error_handler)
625 return d
626
561 def test_contq_changed(self):627 def test_contq_changed(self):
562 """Test the Status.ContentQueueChanged signal."""628 """Test the Status.ContentQueueChanged signal."""
563 # prepare the VM so it lies for us629 # prepare the VM so it lies for us
564630
=== modified file 'ubuntuone/syncdaemon/dbus_interface.py'
--- ubuntuone/syncdaemon/dbus_interface.py 2010-08-25 13:59:42 +0000
+++ ubuntuone/syncdaemon/dbus_interface.py 2010-08-31 18:11:48 +0000
@@ -965,7 +965,8 @@
965 def get_metadata(self, path):965 def get_metadata(self, path):
966 """Return the metadata (as a dict) for the specified path."""966 """Return the metadata (as a dict) for the specified path."""
967 logger.debug('get_metadata by path: %r', path)967 logger.debug('get_metadata by path: %r', path)
968 mdobj = self.fs_manager.get_by_path(path.encode('utf-8'))968 real_path = os.path.realpath(path.encode('utf-8'))
969 mdobj = self.fs_manager.get_by_path(real_path)
969 md_dict = self._mdobj_dict(mdobj)970 md_dict = self._mdobj_dict(mdobj)
970 md_dict['path'] = path971 md_dict['path'] = path
971 return md_dict972 return md_dict
@@ -988,7 +989,8 @@
988 the specified path, including the quick subtree status.989 the specified path, including the quick subtree status.
989 """990 """
990 logger.debug('get_metadata_and_quick_tree_synced: %r', path)991 logger.debug('get_metadata_and_quick_tree_synced: %r', path)
991 mdobj = self.fs_manager.get_by_path(path.encode('utf-8'))992 real_path = os.path.realpath(path.encode('utf-8'))
993 mdobj = self.fs_manager.get_by_path(real_path)
992 md_dict = self._mdobj_dict(mdobj)994 md_dict = self._mdobj_dict(mdobj)
993 md_dict['path'] = path995 md_dict['path'] = path
994 if (self._path_in_queue(path, self.action_queue.meta_queue)996 if (self._path_in_queue(path, self.action_queue.meta_queue)

Subscribers

People subscribed via source and target branches