Merge lp:~facundo/ubuntuone-client/lr-stop-touching-inexistant-nodes into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Facundo Batista
Approved revision: 1142
Merged at revision: 1144
Proposed branch: lp:~facundo/ubuntuone-client/lr-stop-touching-inexistant-nodes
Merge into: lp:ubuntuone-client
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/lr-stop-touching-inexistant-nodes
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Guillermo Gonzalez Approve
Review via email: mp+77604@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
Guillermo Gonzalez (verterok) wrote :

+1

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-08-25 18:27:25 +0000
3+++ tests/syncdaemon/test_fsm.py 2011-09-29 20:30:01 +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_data)
16 self.assertTrue(mdid4 in all_data)
17 self.assertTrue(mdid5 in all_data)
18+ self.assertTrue(mdid9 in all_data)
19 self.assertTrue(mdid6 not in all_data)
20 self.assertTrue(mdid7 not in all_data)
21 self.assertTrue(mdid8 not in all_data)
22@@ -1412,6 +1416,7 @@
23 self.assertTrue(mdid3 not in all_data)
24 self.assertTrue(mdid4 not in all_data)
25 self.assertTrue(mdid5 not in all_data)
26+ self.assertTrue(mdid9 not in all_data)
27 self.assertTrue(mdid6 in all_data)
28 self.assertTrue(mdid7 in all_data)
29 self.assertTrue(mdid8 in all_data)
30@@ -1426,6 +1431,7 @@
31 self.assertTrue(mdid6 not in all_data)
32 self.assertTrue(mdid7 not in all_data)
33 self.assertTrue(mdid8 not in all_data)
34+ self.assertTrue(mdid9 not in all_data)
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-09-12 18:02:10 +0000
41+++ tests/syncdaemon/test_localrescan.py 2011-09-29 20:30:01 +0000
42@@ -853,6 +853,7 @@
43 sh1 = self.create_node(os.path.join("a", "b"), is_dir=True)
44 sh2 = self.create_node(os.path.join("a", "b", "c"), is_dir=True)
45 sh3 = self.create_node(os.path.join("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 remove_tree(sh1)
50
51=== modified file 'ubuntuone/syncdaemon/filesystem_manager.py'
52--- ubuntuone/syncdaemon/filesystem_manager.py 2011-08-25 15:39:57 +0000
53+++ ubuntuone/syncdaemon/filesystem_manager.py 2011-09-29 20:30:01 +0000
54@@ -715,16 +715,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