Merge lp:~diegosarmentero/ubuntuone-client/fixwin-search into lp:ubuntuone-client

Proposed by Diego Sarmentero on 2012-11-05
Status: Merged
Approved by: Brian Curtin on 2012-11-05
Approved revision: 1361
Merged at revision: 1359
Proposed branch: lp:~diegosarmentero/ubuntuone-client/fixwin-search
Merge into: lp:ubuntuone-client
Diff against target: 66 lines (+13/-7)
2 files modified
tests/syncdaemon/test_files_search.py (+8/-4)
ubuntuone/syncdaemon/files_search.py (+5/-3)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-client/fixwin-search
Reviewer Review Type Date Requested Status
Brian Curtin (community) Approve on 2012-11-05
Michał Karnicki (community) 2012-11-05 Approve on 2012-11-05
Review via email: mp+132906@code.launchpad.net

Commit Message

- Using the proper os separator and escaping the base paths (LP: #1073660).

To post a comment you must log in.
1359. By Diego Sarmentero on 2012-11-05

adding new line at the end of the file

1360. By Diego Sarmentero on 2012-11-05

removing unnecessary test

1361. By Diego Sarmentero on 2012-11-05

adding new line at the end

Michał Karnicki (karni) wrote :

Looks good to me.

review: Approve
Brian Curtin (brian.curtin) wrote :

Approved on Windows IRL & tests

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_files_search.py'
2--- tests/syncdaemon/test_files_search.py 2012-10-22 17:17:32 +0000
3+++ tests/syncdaemon/test_files_search.py 2012-11-05 14:41:22 +0000
4@@ -28,6 +28,9 @@
5 # files in the program, then also delete it here.
6 """Test the files search module."""
7
8+import os
9+import re
10+
11 from twisted.internet import defer
12 from twisted.trial.unittest import TestCase
13
14@@ -55,17 +58,18 @@
15 self.pattern = pattern
16
17
18-class FilesystemManagerTestCase(TestCase):
19+class FilesSearchTestCase(TestCase):
20 """Test the SyncMenu."""
21
22 @defer.inlineCallbacks
23 def setUp(self):
24- yield super(FilesystemManagerTestCase, self).setUp()
25+ yield super(FilesSearchTestCase, self).setUp()
26 self.fsm = FakeFilesystemManager()
27 self.search = files_search.SearchFiles(self.fsm)
28 root, udf_dir, shared_dir, _ = self.fsm.vm.get_folders()
29- paths = "(%s|%s|%s)" % (root, udf_dir, shared_dir)
30- self.basic_pattern = paths + ".*/.*%s.*$"
31+ paths = "(%s|%s|%s)" % (re.escape(root), re.escape(udf_dir),
32+ re.escape(shared_dir))
33+ self.basic_pattern = paths + ".*" + os.sep + ".*%s.*$"
34
35 def test_simple_string(self):
36 """Check the pattern is the same string."""
37
38=== modified file 'ubuntuone/syncdaemon/files_search.py'
39--- ubuntuone/syncdaemon/files_search.py 2012-10-22 17:17:32 +0000
40+++ ubuntuone/syncdaemon/files_search.py 2012-11-05 14:41:22 +0000
41@@ -28,6 +28,7 @@
42 # files in the program, then also delete it here.
43 """Searchs for files inside the U1 folder."""
44
45+import os
46 import re
47
48
49@@ -37,12 +38,13 @@
50 def __init__(self, fs):
51 self.fs = fs
52 root, udf_dir, shared_dir, _ = self.fs.vm.get_folders()
53- paths = "(%s|%s|%s)" % (root, udf_dir, shared_dir)
54- self.pattern = paths + ".*/.*%s.*$"
55+ paths = "(%s|%s|%s)" % (re.escape(root), re.escape(udf_dir),
56+ re.escape(shared_dir))
57+ self.pattern = paths + ".*" + os.sep + ".*%s.*$"
58
59 def search(self, pattern=''):
60 """Search for the files that contains name."""
61 keywords = '.+'.join(re.escape(pattern).split('\\ '))
62 search = self.pattern % keywords
63 results = self.fs.get_paths_by_pattern(search)
64- return results
65\ No newline at end of file
66+ return results

Subscribers

People subscribed via source and target branches