Merge lp:~facundo/ubuntuone-client/fix-getbynodeid--1-6 into lp:ubuntuone-client/stable-1-6

Proposed by Facundo Batista
Status: Merged
Approved by: dobey
Approved revision: 968
Merged at revision: 969
Proposed branch: lp:~facundo/ubuntuone-client/fix-getbynodeid--1-6
Merge into: lp:ubuntuone-client/stable-1-6
Diff against target: 78 lines (+15/-5)
3 files modified
tests/syncdaemon/test_fsm.py (+6/-0)
tests/syncdaemon/test_localrescan.py (+1/-0)
ubuntuone/syncdaemon/filesystem_manager.py (+8/-5)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/fix-getbynodeid--1-6
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
John O'Brien (community) Approve
Review via email: mp+77696@code.launchpad.net

Commit message

Fix filter by share and path (LP: #807737).

Description of the change

Fix filter by share and path.

Avoid returning directories that had names starting with the one is asked.

Tests included

To post a comment you must log in.
Revision history for this message
John O'Brien (jdobrien) wrote :

Looks good.

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

Approving with one review.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/syncdaemon/test_fsm.py'
--- tests/syncdaemon/test_fsm.py 2011-04-05 19:51:24 +0000
+++ tests/syncdaemon/test_fsm.py 2011-09-30 12:49:29 +0000
@@ -1382,6 +1382,9 @@
1382 path5 = os.path.join(share1.path, "c")1382 path5 = os.path.join(share1.path, "c")
1383 mdid5 = self.fsm.create(path5, "share_id1")1383 mdid5 = self.fsm.create(path5, "share_id1")
1384 self.fsm.set_node_id(path5, "uuid5")1384 self.fsm.set_node_id(path5, "uuid5")
1385 path9 = os.path.join(share1.path, "aaa")
1386 mdid9 = self.fsm.create(path9, "share_id1")
1387 self.fsm.set_node_id(path9, "uuid9")
13851388
1386 # create some nodes in share 21389 # create some nodes in share 2
1387 path6 = os.path.join(share2.path, "a")1390 path6 = os.path.join(share2.path, "a")
@@ -1402,6 +1405,7 @@
1402 self.assertTrue(mdid3 in all)1405 self.assertTrue(mdid3 in all)
1403 self.assertTrue(mdid4 in all)1406 self.assertTrue(mdid4 in all)
1404 self.assertTrue(mdid5 in all)1407 self.assertTrue(mdid5 in all)
1408 self.assertTrue(mdid9 in all)
1405 self.assertTrue(mdid6 not in all)1409 self.assertTrue(mdid6 not in all)
1406 self.assertTrue(mdid7 not in all)1410 self.assertTrue(mdid7 not in all)
1407 self.assertTrue(mdid8 not in all)1411 self.assertTrue(mdid8 not in all)
@@ -1412,6 +1416,7 @@
1412 self.assertTrue(mdid3 not in all)1416 self.assertTrue(mdid3 not in all)
1413 self.assertTrue(mdid4 not in all)1417 self.assertTrue(mdid4 not in all)
1414 self.assertTrue(mdid5 not in all)1418 self.assertTrue(mdid5 not in all)
1419 self.assertTrue(mdid9 not in all)
1415 self.assertTrue(mdid6 in all)1420 self.assertTrue(mdid6 in all)
1416 self.assertTrue(mdid7 in all)1421 self.assertTrue(mdid7 in all)
1417 self.assertTrue(mdid8 in all)1422 self.assertTrue(mdid8 in all)
@@ -1426,6 +1431,7 @@
1426 self.assertTrue(mdid6 not in all)1431 self.assertTrue(mdid6 not in all)
1427 self.assertTrue(mdid7 not in all)1432 self.assertTrue(mdid7 not in all)
1428 self.assertTrue(mdid8 not in all)1433 self.assertTrue(mdid8 not in all)
1434 self.assertTrue(mdid9 not in all)
14291435
1430 @defer.inlineCallbacks1436 @defer.inlineCallbacks
1431 def test_get_all_by_share_mixed(self):1437 def test_get_all_by_share_mixed(self):
14321438
=== modified file 'tests/syncdaemon/test_localrescan.py'
--- tests/syncdaemon/test_localrescan.py 2011-04-05 19:33:06 +0000
+++ tests/syncdaemon/test_localrescan.py 2011-09-30 12:49:29 +0000
@@ -886,6 +886,7 @@
886 sh1 = self.create_node("a/b", is_dir=True)886 sh1 = self.create_node("a/b", is_dir=True)
887 sh2 = self.create_node("a/b/c", is_dir=True)887 sh2 = self.create_node("a/b/c", is_dir=True)
888 sh3 = self.create_node("a/b/c/d", is_dir=False)888 sh3 = self.create_node("a/b/c/d", is_dir=False)
889 self.create_node(os.path.join("a", "bar"), is_dir=False)
889890
890 # remove the whole subtree891 # remove the whole subtree
891 shutil.rmtree(sh1)892 shutil.rmtree(sh1)
892893
=== modified file 'ubuntuone/syncdaemon/filesystem_manager.py'
--- ubuntuone/syncdaemon/filesystem_manager.py 2011-04-05 19:51:24 +0000
+++ ubuntuone/syncdaemon/filesystem_manager.py 2011-09-30 12:49:29 +0000
@@ -710,16 +710,19 @@
710 path, mdobj['mdid'], share_id, node_id)710 path, mdobj['mdid'], share_id, node_id)
711711
712 def get_mdobjs_by_share_id(self, share_id, base_path=None):712 def get_mdobjs_by_share_id(self, share_id, base_path=None):
713 """Returns all the mdobj that belongs to a share and it path713 """Get all the mdobjs from a share.
714 startswith base_path.714
715 If base_path is present, only return those who start with (or
716 are equal to) that path.
715 """717 """
716 if base_path is None:718 if base_path is None:
717 base_path = self._get_share(share_id).path719 base_path = self._get_share(share_id).path
720 compare_path = base_path + os.path.sep
721
718 all_mdobjs = []722 all_mdobjs = []
719 # filter by path first, so we don't touch disk723 # filter by path first, so we don't touch disk
720 for path in self._idx_path:724 for path, mdid in self._idx_path.iteritems():
721 if path.startswith(base_path):725 if path == base_path or path.startswith(compare_path):
722 mdid = self._idx_path[path]
723 mdobj = self.fs[mdid]726 mdobj = self.fs[mdid]
724 if mdobj["share_id"] == share_id:727 if mdobj["share_id"] == share_id:
725 all_mdobjs.append(_MDObject(**mdobj))728 all_mdobjs.append(_MDObject(**mdobj))

Subscribers

People subscribed via source and target branches