Merge lp:~nataliabidart/ubuntuone-client/no-custom-abspath into lp:ubuntuone-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 1057
Merged at revision: 1055
Proposed branch: lp:~nataliabidart/ubuntuone-client/no-custom-abspath
Merge into: lp:ubuntuone-client
Diff against target: 408 lines (+45/-65)
8 files modified
tests/platform/test_filesystem_notifications.py (+0/-1)
tests/syncdaemon/test_vm.py (+37/-37)
ubuntuone/platform/linux/__init__.py (+0/-1)
ubuntuone/platform/linux/os_helper.py (+0/-5)
ubuntuone/platform/windows/__init__.py (+0/-1)
ubuntuone/platform/windows/os_helper.py (+1/-11)
ubuntuone/syncdaemon/filesystem_manager.py (+1/-2)
ubuntuone/syncdaemon/volume_manager.py (+6/-7)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-client/no-custom-abspath
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+68418@code.launchpad.net

Commit message

- No more custom abspath, credits to Manuel de la Peña (LP: #812976).

To post a comment you must log in.
1057. By Natalia Bidart

Removing no longer valid comments about prepending \\?\ when dealing with tritcask.

Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks great. Thanks mandel and nessita!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/platform/test_filesystem_notifications.py'
2--- tests/platform/test_filesystem_notifications.py 2011-04-19 15:33:42 +0000
3+++ tests/platform/test_filesystem_notifications.py 2011-07-19 16:19:28 +0000
4@@ -84,7 +84,6 @@
5 self.root_dir = platform_mangled_path(self.mktemp('root_dir'))
6 self.home_dir = platform_mangled_path(self.mktemp('home_dir'))
7 self.vm = testcase.FakeVolumeManager(self.root_dir)
8- # FIXME: Trictask cannot deal with \\\\?\\ infornt of files
9 self.tritcask_dir = self.mktemp("tritcask_dir")
10 self.db = Tritcask(self.tritcask_dir)
11 self.fs = filesystem_manager.FileSystemManager(fsmdir, partials_dir,
12
13=== modified file 'tests/syncdaemon/test_vm.py'
14--- tests/syncdaemon/test_vm.py 2011-07-08 12:21:59 +0000
15+++ tests/syncdaemon/test_vm.py 2011-07-19 16:19:28 +0000
16@@ -59,7 +59,6 @@
17 VolumeDoesNotExist,
18 )
19 from ubuntuone.platform import (
20- abspath,
21 get_udf_path,
22 make_link,
23 make_dir,
24@@ -576,7 +575,7 @@
25 'Modify')
26 # initialize the the root
27 self.vm._got_root('root_uuid')
28- shared_dir = abspath(os.path.join(self.root_dir, 'shared_dir'))
29+ shared_dir = os.path.abspath(os.path.join(self.root_dir, 'shared_dir'))
30 self.main.fs.create(path=shared_dir, share_id="", is_dir=True)
31 self.main.fs.set_node_id(shared_dir, shared_response.subtree)
32 response = ListShares(None)
33@@ -628,7 +627,7 @@
34 self.assertEquals('View', access_level)
35 self.assertTrue(marker is not None)
36 share = self.vm.marker_share_map[marker]
37- self.assertEquals(abspath(path), share.path)
38+ self.assertEquals(os.path.abspath(path), share.path)
39 self.assertEquals('View', share.access_level)
40 self.assertEquals(marker, share.volume_id)
41 self.assertEquals('fake_user', share.other_username)
42@@ -654,7 +653,7 @@
43 @defer.inlineCallbacks
44 def test_create_share_missing_node_id(self):
45 """Test VolumeManager.create_share in the case of missing node_id."""
46- path = abspath(os.path.join(self.vm.root.path, 'shared_path'))
47+ path = os.path.abspath(os.path.join(self.vm.root.path, 'shared_path'))
48 self.main.fs.create(path, "")
49 expected_node_id = uuid.uuid4()
50 expected_share_id = uuid.uuid4()
51@@ -877,9 +876,7 @@
52 for path in paths:
53 self.assertTrue(self.main.event_q.has_watch(path))
54 # remove the watches
55- # TODO: because tritcask does not work well with \\?\ we are adding it
56- # here rather than in mktemp which is the correct place to do it
57- self.vm._remove_watches(abspath(self.root_dir))
58+ self.vm._remove_watches(os.path.abspath(self.root_dir))
59 for path in paths:
60 self.assertFalse(self.main.event_q.has_watch(path), path)
61
62@@ -893,16 +890,14 @@
63
64 os.rename(path, path+'.old')
65 # remove the watches
66- # TODO: because tritcask does not work well with \\?\ we are adding it
67- # here rather than in mktemp which is the correct place to do it
68- self.vm._remove_watches(abspath(self.root_dir))
69+ self.vm._remove_watches(os.path.abspath(self.root_dir))
70
71 self.assertFalse(self.main.event_q.has_watch(path),
72 'watch should not be present')
73
74 def test_delete_fsm_object(self):
75 """Test for VolumeManager._delete_fsm_object"""
76- path = abspath(os.path.join(self.root_dir, 'dir'))
77+ path = os.path.abspath(os.path.join(self.root_dir, 'dir'))
78 make_dir(path, recursive=True)
79 self.main.fs.create(path, "", is_dir=True)
80 self.main.fs.set_node_id(path, 'dir_node_id')
81@@ -1217,7 +1212,7 @@
82 dirs = ['dir', os.path.join('dir','subdir'),
83 os.path.join('dir', 'empty_dir')]
84 for i, dir in enumerate(dirs):
85- path = abspath(os.path.join(share.path, dir))
86+ path = os.path.abspath(os.path.join(share.path, dir))
87 with allow_writes(os.path.split(share.path)[0]):
88 with allow_writes(share.path):
89 if not os.path.exists(path):
90@@ -1227,7 +1222,7 @@
91 files = ['a_file', os.path.join('dir', 'file'),
92 os.path.join('dir', 'subdir', 'file')]
93 for i, path in enumerate(files):
94- path = abspath(os.path.join(share.path, path))
95+ path = os.path.abspath(os.path.join(share.path, path))
96 with allow_writes(os.path.split(share.path)[0]):
97 with allow_writes(share.path):
98 open(path, 'w').close()
99@@ -1292,7 +1287,7 @@
100 share = self.vm.shares['share_id']
101 shouldbe_dir = os.path.join(self.shares_dir,
102 get_share_dir_name(share_response))
103- self.assertEquals(abspath(shouldbe_dir), share.path)
104+ self.assertEquals(os.path.abspath(shouldbe_dir), share.path)
105
106 def test_handle_SHARES_visible_username(self):
107 """test the handling of AQ_SHARE_LIST with non-ascii visible uname."""
108@@ -1311,7 +1306,7 @@
109 share = self.vm.shares['share_id']
110 shouldbe_dir = os.path.join(self.shares_dir,
111 get_share_dir_name(share_response))
112- self.assertEquals(abspath(shouldbe_dir), share.path)
113+ self.assertEquals(os.path.abspath(shouldbe_dir), share.path)
114
115 def test_handle_SV_SHARE_CHANGED_sharename(self):
116 """test the handling of SV_SHARE_CHANGED for non-ascii share name."""
117@@ -1323,8 +1318,8 @@
118 self.vm.handle_SV_SHARE_CHANGED(info=share_holder)
119 shouldbe_dir = os.path.join(self.shares_dir,
120 get_share_dir_name(share_holder))
121- self.assertEquals(abspath(shouldbe_dir),
122- abspath(self.vm.shares['share_id'].path))
123+ self.assertEquals(os.path.abspath(shouldbe_dir),
124+ os.path.abspath(self.vm.shares['share_id'].path))
125
126 def test_handle_SV_SHARE_CHANGED_visible(self):
127 """test the handling of SV_SHARE_CHANGED for non-ascii visible name."""
128@@ -1336,8 +1331,8 @@
129 self.vm.handle_SV_SHARE_CHANGED(info=share_holder)
130 shouldbe_dir = os.path.join(self.shares_dir,
131 get_share_dir_name(share_holder))
132- self.assertEquals(abspath(shouldbe_dir),
133- abspath(self.vm.shares['share_id'].path))
134+ self.assertEquals(os.path.abspath(shouldbe_dir),
135+ os.path.abspath(self.vm.shares['share_id'].path))
136
137
138 class VolumeManagerVolumesTests(BaseVolumeManagerTests):
139@@ -1358,7 +1353,8 @@
140
141 with environ('HOME', self.home_dir):
142 udf = self._create_udf(suggested_path=suggested_path)
143- self.assertEquals(map(abspath, map(os.path.expanduser, expected)),
144+ self.assertEquals(map(os.path.abspath,
145+ map(os.path.expanduser, expected)),
146 udf.ancestors)
147
148 @defer.inlineCallbacks
149@@ -1368,8 +1364,8 @@
150 udf = self._create_udf(suggested_path='~/' + suggested_path,
151 subscribed=False)
152 yield self.vm.add_udf(udf)
153- self.assertEquals(abspath(os.path.join(self.home_dir, suggested_path)),
154- abspath(udf.path))
155+ self.assertEquals(os.path.abspath(os.path.join(self.home_dir, suggested_path)),
156+ os.path.abspath(udf.path))
157 self.assertEquals(1, len(self.vm.udfs))
158 # check that the UDF is in the fsm metadata
159 mdobj = self.main.fs.get_by_path(udf.path)
160@@ -1383,8 +1379,8 @@
161 # add it again, but this time with subscribed = True
162 udf.subscribed = True
163 yield self.vm.add_udf(udf)
164- self.assertEquals(abspath(os.path.join(self.home_dir, suggested_path)),
165- abspath(udf.path))
166+ self.assertEquals(os.path.abspath(os.path.join(self.home_dir, suggested_path)),
167+ os.path.abspath(udf.path))
168 self.assertEquals(1, len(self.vm.udfs))
169 # check that the UDF is in the fsm metadata
170 mdobj = self.main.fs.get_by_path(udf.path)
171@@ -1531,8 +1527,8 @@
172 self.assertEqual('fake_share_uuid', share.node_id)
173 udf = self.vm.udfs[str(udf_id)]
174 self.assertEqual('udf_uuid', udf.node_id)
175- self.assertEqual(abspath(os.path.join(self.home_dir, 'UDF')),
176- abspath(udf.path))
177+ self.assertEqual(os.path.abspath(os.path.join(self.home_dir, 'UDF')),
178+ os.path.abspath(udf.path))
179 # check that the root it's there, have right node_id and generation
180 self.assertIn(request.ROOT, self.vm.shares)
181 root = self.vm.shares[request.ROOT]
182@@ -1599,9 +1595,9 @@
183 self.assertEqual('fake_share_uuid', share.node_id)
184 udf = self.vm.udfs[str(udf_id)]
185 self.assertEqual('udf_uuid', udf.node_id)
186- self.assertEqual(abspath(os.path.join(self.home_dir,
187- u'ñoño'.encode("utf8"))),
188- abspath(udf.path))
189+ self.assertEqual(os.path.abspath(os.path.join(self.home_dir,
190+ u'ñoño'.encode("utf8"))),
191+ os.path.abspath(udf.path))
192
193 def test_handle_AQ_LIST_VOLUMES_root(self):
194 """Test the handling of the AQ_LIST_VOLUMES event."""
195@@ -1778,8 +1774,8 @@
196 self.assertIn(str(udf_id), self.vm.udfs)
197 udf = self.vm.udfs[str(udf_id)]
198 self.assertEqual('udf_uuid', udf.node_id)
199- self.assertEqual(abspath(os.path.join(self.home_dir, 'UDF')),
200- abspath(udf.path))
201+ self.assertEqual(os.path.abspath(os.path.join(self.home_dir, 'UDF')),
202+ os.path.abspath(udf.path))
203 if auto_subscribe:
204 # root and udf
205 self.assertEqual(2, len(list(self.vm.get_volumes())))
206@@ -1839,7 +1835,8 @@
207 def check(info):
208 """Check the udf attributes."""
209 udf = info['udf']
210- self.assertEquals(abspath(udf.path), abspath(path))
211+ self.assertEquals(os.path.abspath(udf.path),
212+ os.path.abspath(path))
213 self.assertEquals(udf.volume_id, str(udf_id))
214 self.assertEquals(udf.node_id, str(node_id))
215 self.assertEquals(udf.suggested_path, u'~/MyUDF')
216@@ -1898,7 +1895,8 @@
217 def check_udf(info):
218 """Check the udf attributes."""
219 deleted_udf = info['volume']
220- self.assertEquals(abspath(deleted_udf.path), abspath(udf.path))
221+ self.assertEquals(os.path.abspath(deleted_udf.path),
222+ os.path.abspath(udf.path))
223 self.assertEquals(deleted_udf.volume_id, udf.volume_id)
224 self.assertEquals(deleted_udf.node_id, udf.node_id)
225 self.assertEquals(deleted_udf.suggested_path, udf.suggested_path)
226@@ -1912,7 +1910,7 @@
227 def check_share(info):
228 """Check the share attributes."""
229 deleted_share = info['volume']
230- self.assertEquals(abspath(deleted_share.path), share.path)
231+ self.assertEquals(os.path.abspath(deleted_share.path), share.path)
232 self.assertEquals(deleted_share.volume_id, share.volume_id)
233 self.assertEquals(deleted_share.node_id, share.node_id)
234 self.assertNotIn(deleted_share.volume_id, self.vm.shares)
235@@ -2230,7 +2228,7 @@
236 def check(info):
237 """The callback"""
238 udf = info['udf']
239- self.assertEquals(abspath(udf.path), abspath(path))
240+ self.assertEquals(os.path.abspath(udf.path), os.path.abspath(path))
241 self.assertEquals(udf.volume_id, str(udf_id))
242 self.assertEquals(udf.node_id, str(node_id))
243 self.assertEquals(0, len(self.vm.marker_udf_map))
244@@ -2276,7 +2274,8 @@
245 def check(info):
246 """Check the udf attributes."""
247 deleted_udf = info['volume']
248- self.assertEquals(abspath(deleted_udf.path), abspath(udf.path))
249+ self.assertEquals(os.path.abspath(deleted_udf.path),
250+ os.path.abspath(udf.path))
251 self.assertEquals(deleted_udf.volume_id, udf.volume_id)
252 self.assertEquals(deleted_udf.node_id, udf.node_id)
253 self.assertEquals(deleted_udf.suggested_path, udf.suggested_path)
254@@ -3368,7 +3367,8 @@
255 mdobj = self.main.fs.get_by_path(udf.path)
256 self.assertEquals(udf.node_id, mdobj.node_id)
257 self.assertEquals(udf.id, mdobj.share_id)
258- self.assertEquals(abspath(udf.path), abspath(mdobj.path))
259+ self.assertEquals(os.path.abspath(udf.path),
260+ os.path.abspath(mdobj.path))
261
262 @defer.inlineCallbacks
263 def test_volumes_rescan_cb_active_udf(self):
264
265=== modified file 'ubuntuone/platform/linux/__init__.py'
266--- ubuntuone/platform/linux/__init__.py 2011-07-08 12:21:59 +0000
267+++ ubuntuone/platform/linux/__init__.py 2011-07-19 16:19:28 +0000
268@@ -26,7 +26,6 @@
269 from dbus.mainloop.glib import DBusGMainLoop
270
271 from ubuntuone.platform.linux.os_helper import (
272- abspath,
273 access,
274 allow_writes,
275 can_write,
276
277=== modified file 'ubuntuone/platform/linux/os_helper.py'
278--- ubuntuone/platform/linux/os_helper.py 2011-06-24 01:45:01 +0000
279+++ ubuntuone/platform/linux/os_helper.py 2011-07-19 16:19:28 +0000
280@@ -169,11 +169,6 @@
281 return os.path.abspath(path).split(os.path.sep)
282
283
284-def abspath(path):
285- """Return an abspath."""
286- return os.path.abspath(path)
287-
288-
289 def normpath(path):
290 """Normalize path, eliminating double slashes, etc."""
291 return os.path.normpath(path)
292\ No newline at end of file
293
294=== modified file 'ubuntuone/platform/windows/__init__.py'
295--- ubuntuone/platform/windows/__init__.py 2011-07-08 12:21:59 +0000
296+++ ubuntuone/platform/windows/__init__.py 2011-07-19 16:19:28 +0000
297@@ -32,7 +32,6 @@
298
299
300 from ubuntuone.platform.windows.os_helper import (
301- abspath,
302 access,
303 allow_writes,
304 can_write,
305
306=== modified file 'ubuntuone/platform/windows/os_helper.py'
307--- ubuntuone/platform/windows/os_helper.py 2011-06-24 01:45:57 +0000
308+++ ubuntuone/platform/windows/os_helper.py 2011-07-19 16:19:28 +0000
309@@ -468,7 +468,7 @@
310 path += '.lnk'
311 shell = Dispatch('WScript.Shell')
312 shortcut = shell.CreateShortCut(path)
313- return abspath(shortcut.Targetpath)
314+ return os.path.abspath(shortcut.Targetpath)
315
316
317 @absparam(paths_indexes=[0])
318@@ -599,16 +599,6 @@
319 return list
320
321
322-def abspath(path):
323- """Return an abspath."""
324- # TODO: do we really need to do this, are the tests broken?
325- path = path.replace('/', '\\')
326- abs = os.path.abspath(remove_windows_illegal_chars(path))
327- if not LONG_PATH_PREFIX in abs:
328- abs = LONG_PATH_PREFIX + abs
329- return abs
330-
331-
332 def normpath(path):
333 """Normalize path, eliminating double slashes, etc."""
334 # the basic normpath does not work correctly with \\?\ which we use
335
336=== modified file 'ubuntuone/syncdaemon/filesystem_manager.py'
337--- ubuntuone/syncdaemon/filesystem_manager.py 2011-06-24 01:48:27 +0000
338+++ ubuntuone/syncdaemon/filesystem_manager.py 2011-07-19 16:19:28 +0000
339@@ -49,7 +49,6 @@
340 set_file_readwrite,
341 stat_path,
342 )
343-from ubuntuone.platform import abspath as os_abspath
344 from ubuntuone.platform import open_file as os_open
345
346 METADATA_VERSION = "6"
347@@ -1305,7 +1304,7 @@
348 # the relaitve path is the fullpath
349 return share_path
350 else:
351- return os_abspath(os.path.join(share_path, path))
352+ return os.path.abspath(os.path.join(share_path, path))
353
354 def _enable_share_write(self, share_id, path, recursive=False):
355 """Helper to create a EnableShareWrite context manager."""
356
357=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
358--- ubuntuone/syncdaemon/volume_manager.py 2011-07-08 12:21:59 +0000
359+++ ubuntuone/syncdaemon/volume_manager.py 2011-07-19 16:19:28 +0000
360@@ -27,14 +27,17 @@
361 import sys
362 import shutil
363 import stat
364+
365 from itertools import ifilter
366
367+from twisted.internet import defer
368 from ubuntuone.storageprotocol import request
369 from ubuntuone.storageprotocol.volumes import (
370 ShareVolume,
371 UDFVolume,
372 RootVolume,
373 )
374+
375 from ubuntuone.syncdaemon.marker import MDMarker
376 from ubuntuone.syncdaemon.interfaces import IMarker
377 from ubuntuone.syncdaemon import file_shelf, config
378@@ -57,10 +60,6 @@
379 set_dir_readonly,
380 set_dir_readwrite
381 )
382-from ubuntuone.platform import abspath as os_abspath
383-
384-from twisted.internet import defer
385-
386
387 # tritcask row types
388 SHARE_ROW_TYPE = 3
389@@ -1501,8 +1500,8 @@
390 and os.path.exists(self._shared_md_dir):
391 # we have shares and shared dirs
392 # md_version >= 1
393- old_root_dir = os_abspath(os.path.join(self._root_dir, 'My Files'))
394- old_share_dir = os_abspath(os.path.join(self._root_dir,
395+ old_root_dir = os.path.abspath(os.path.join(self._root_dir, 'My Files'))
396+ old_share_dir = os.path.abspath(os.path.join(self._root_dir,
397 'Shared With Me'))
398 if os.path.exists(old_share_dir) and os.path.exists(old_root_dir) \
399 and not is_link(old_share_dir):
400@@ -1521,7 +1520,7 @@
401 except OSError:
402 target = None
403 if is_link(self._shares_dir_link) \
404- and normpath(target) == os_abspath(self._shares_dir_link):
405+ and normpath(target) == os.path.abspath(self._shares_dir_link):
406 # broken symlink, md_version = 4
407 md_version = '4'
408 else:

Subscribers

People subscribed via source and target branches