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
1=== modified file 'tests/syncdaemon/test_fsm.py'
2--- tests/syncdaemon/test_fsm.py 2011-04-05 19:51:24 +0000
3+++ tests/syncdaemon/test_fsm.py 2011-09-30 12:49:29 +0000
4@@ -1382,6 +1382,9 @@
5 path5 = os.path.join(share1.path, "c")
6 mdid5 = self.fsm.create(path5, "share_id1")
7 self.fsm.set_node_id(path5, "uuid5")
8+ path9 = os.path.join(share1.path, "aaa")
9+ mdid9 = self.fsm.create(path9, "share_id1")
10+ self.fsm.set_node_id(path9, "uuid9")
11
12 # create some nodes in share 2
13 path6 = os.path.join(share2.path, "a")
14@@ -1402,6 +1405,7 @@
15 self.assertTrue(mdid3 in all)
16 self.assertTrue(mdid4 in all)
17 self.assertTrue(mdid5 in all)
18+ self.assertTrue(mdid9 in all)
19 self.assertTrue(mdid6 not in all)
20 self.assertTrue(mdid7 not in all)
21 self.assertTrue(mdid8 not in all)
22@@ -1412,6 +1416,7 @@
23 self.assertTrue(mdid3 not in all)
24 self.assertTrue(mdid4 not in all)
25 self.assertTrue(mdid5 not in all)
26+ self.assertTrue(mdid9 not in all)
27 self.assertTrue(mdid6 in all)
28 self.assertTrue(mdid7 in all)
29 self.assertTrue(mdid8 in all)
30@@ -1426,6 +1431,7 @@
31 self.assertTrue(mdid6 not in all)
32 self.assertTrue(mdid7 not in all)
33 self.assertTrue(mdid8 not in all)
34+ self.assertTrue(mdid9 not in all)
35
36 @defer.inlineCallbacks
37 def test_get_all_by_share_mixed(self):
38
39=== modified file 'tests/syncdaemon/test_localrescan.py'
40--- tests/syncdaemon/test_localrescan.py 2011-04-05 19:33:06 +0000
41+++ tests/syncdaemon/test_localrescan.py 2011-09-30 12:49:29 +0000
42@@ -886,6 +886,7 @@
43 sh1 = self.create_node("a/b", is_dir=True)
44 sh2 = self.create_node("a/b/c", is_dir=True)
45 sh3 = self.create_node("a/b/c/d", is_dir=False)
46+ self.create_node(os.path.join("a", "bar"), is_dir=False)
47
48 # remove the whole subtree
49 shutil.rmtree(sh1)
50
51=== modified file 'ubuntuone/syncdaemon/filesystem_manager.py'
52--- ubuntuone/syncdaemon/filesystem_manager.py 2011-04-05 19:51:24 +0000
53+++ ubuntuone/syncdaemon/filesystem_manager.py 2011-09-30 12:49:29 +0000
54@@ -710,16 +710,19 @@
55 path, mdobj['mdid'], share_id, node_id)
56
57 def get_mdobjs_by_share_id(self, share_id, base_path=None):
58- """Returns all the mdobj that belongs to a share and it path
59- startswith base_path.
60+ """Get all the mdobjs from a share.
61+
62+ If base_path is present, only return those who start with (or
63+ are equal to) that path.
64 """
65 if base_path is None:
66 base_path = self._get_share(share_id).path
67+ compare_path = base_path + os.path.sep
68+
69 all_mdobjs = []
70 # filter by path first, so we don't touch disk
71- for path in self._idx_path:
72- if path.startswith(base_path):
73- mdid = self._idx_path[path]
74+ for path, mdid in self._idx_path.iteritems():
75+ if path == base_path or path.startswith(compare_path):
76 mdobj = self.fs[mdid]
77 if mdobj["share_id"] == share_id:
78 all_mdobjs.append(_MDObject(**mdobj))

Subscribers

People subscribed via source and target branches