Merge lp:~verterok/ubuntuone-client/bad-share-path into lp:ubuntuone-client
- bad-share-path
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | John Lenton |
Approved revision: | 191 |
Merged at revision: | not available |
Proposed branch: | lp:~verterok/ubuntuone-client/bad-share-path |
Merge into: | lp:ubuntuone-client |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~verterok/ubuntuone-client/bad-share-path |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Rick McBride (community) | Approve | ||
Review via email: mp+10812@code.launchpad.net |
Commit message
update FSM metadata for the new layout.
Description of the change
Guillermo Gonzalez (verterok) wrote : | # |
Rick McBride (rmcbride) wrote : | # |
This looks good. I actually built packages from it and ran against the live server and it works nicely.
John Lenton (chipaca) : | # |
dobey (dobey) wrote : | # |
/usr/bin/
[1mchecking for autoconf >= 2.53...
[m(B testing autoconf2.50... not found.
testing autoconf... found 2.64
[1mchecking for automake >= 1.10...
[m(B testing automake-1.11... found 1.11
[1mchecking for libtool >= 1.5...
[m(B testing libtoolize... found 2.2.6
[1mchecking for intltool >= 0.30...
[m(B testing intltoolize... found 0.40.6
[1mchecking for pkg-config >= 0.14.0...
[m(B testing pkg-config... found 0.22
[1mChecking for required M4 macros...
[m(B[1mChecking for forbidden M4 macros...
[m(B
[m(B[1mRunning libtoolize...
[m(Blibtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
[1mRunning intltoolize...
[m(B[1mRunning aclocal-1.11...
[m(B[1mRunning autoconf...
[m(B[1mRunning autoheader...
[m(B[1mRunning automake-1.11...
[m(B[1mRunning ./configure --enable-
[m(Bchecking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking fo...
- 192. By Guillermo Gonzalez
-
update tests
Preview Diff
1 | === modified file 'tests/syncdaemon/test_fsm.py' |
2 | --- tests/syncdaemon/test_fsm.py 2009-08-14 18:37:28 +0000 |
3 | +++ tests/syncdaemon/test_fsm.py 2009-08-27 19:57:42 +0000 |
4 | @@ -230,6 +230,21 @@ |
5 | open(path, "w").close() |
6 | mdid = self.fsm.create(path, "share") |
7 | self.fsm.set_node_id(path, "uuid") |
8 | + # create a path with the old layout |
9 | + other_share = self.create_share('share1', 'share1_name', |
10 | + self.fsm, self.shares_dir) |
11 | + share_mdid = self.fsm.create(other_share.path, "share1") |
12 | + self.fsm.set_node_id(other_share.path, "uuid1") |
13 | + os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
14 | + old_shares_path = os.path.join(self.root_dir, 'Ubuntu One', |
15 | + 'Shared With Me') |
16 | + old_path = os.path.join(old_shares_path, 'share1_name') |
17 | + os.symlink(self.shares_dir, old_shares_path) |
18 | + |
19 | + # put the old path in the mdobj |
20 | + share_md = self.fsm.fs[share_mdid] |
21 | + share_md['path'] = old_path |
22 | + self.fsm.fs[share_mdid] = share_md |
23 | |
24 | # break the node on purpose |
25 | real_mdobj = self.fsm.fs[mdid] |
26 | @@ -246,13 +261,16 @@ |
27 | # start up again, and check |
28 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
29 | md_version = open(version_file).read() |
30 | - self.assertEqual(md_version, "3") |
31 | + self.assertEqual(md_version, "4") |
32 | newmdobj = newfsm.get_by_path(path) |
33 | self.assertEqual(newmdobj.mdid, mdid) |
34 | self.assertEqual(newmdobj.stat, os.stat(path)) |
35 | self.assertEqual(newmdobj.local_hash, "") |
36 | self.assertEqual(newmdobj.server_hash, "") |
37 | self.assertTrue(isinstance(newmdobj.path, str)) |
38 | + self.assertTrue(other_share.path in newfsm._idx_path) |
39 | + self.assertFalse(old_path in self.fsm._idx_path) |
40 | + self.assertFalse(old_path in newfsm._idx_path) |
41 | |
42 | def test_old_metadata_1(self): |
43 | '''Faking an old metadata situation, in v1.''' |
44 | @@ -264,6 +282,22 @@ |
45 | mdid2 = self.fsm.create(path2, "share") |
46 | self.fsm.set_node_id(path2, "uuid2") |
47 | |
48 | + # create a path with the old layout |
49 | + other_share = self.create_share('share1', 'share1_name', |
50 | + self.fsm, self.shares_dir) |
51 | + share_mdid = self.fsm.create(other_share.path, "share1") |
52 | + self.fsm.set_node_id(other_share.path, "uuid1") |
53 | + os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
54 | + old_shares_path = os.path.join(self.root_dir, 'Ubuntu One', |
55 | + 'Shared With Me') |
56 | + old_path = os.path.join(old_shares_path, 'share1_name') |
57 | + os.symlink(self.shares_dir, old_shares_path) |
58 | + |
59 | + # put the old path in the mdobj |
60 | + share_md = self.fsm.fs[share_mdid] |
61 | + share_md['path'] = old_path |
62 | + self.fsm.fs[share_mdid] = share_md |
63 | + |
64 | # break the node on purpose, with unicode valid and not |
65 | real_mdobj = self.fsm.fs[mdid1] |
66 | real_mdobj["path"] = unicode(real_mdobj["path"]) |
67 | @@ -282,14 +316,16 @@ |
68 | # start up again, and check |
69 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
70 | md_version = open(version_file).read() |
71 | - self.assertEqual(md_version, "3") |
72 | + self.assertEqual(md_version, "4") |
73 | newmdobj = newfsm.get_by_path(path1) |
74 | self.assertEqual(newmdobj.mdid, mdid1) |
75 | self.assertEqual(newmdobj.local_hash, "") |
76 | self.assertEqual(newmdobj.server_hash, "") |
77 | self.assertTrue(isinstance(newmdobj.path, str)) |
78 | # pylint: disable-msg=W0212 |
79 | - self.assertEqual(1, len(newfsm._idx_node_id)) |
80 | + self.assertEqual(2, len(newfsm._idx_node_id)) |
81 | + self.assertTrue(other_share.path in newfsm._idx_path) |
82 | + self.assertFalse(old_path in newfsm._idx_path) |
83 | |
84 | def test_old_metadata_2(self): |
85 | '''Faking an old metadata situation, in v2.''' |
86 | @@ -297,6 +333,21 @@ |
87 | path = os.path.join(self.share.path, 'path') |
88 | mdid = self.fsm.create(path, "share") |
89 | self.fsm.set_node_id(path, "uuid") |
90 | + # create a path with the old layout |
91 | + other_share = self.create_share('share1', 'share1_name', |
92 | + self.fsm, self.shares_dir) |
93 | + share_mdid = self.fsm.create(other_share.path, "share1") |
94 | + self.fsm.set_node_id(other_share.path, "uuid1") |
95 | + os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
96 | + old_shares_path = os.path.join(self.root_dir, 'Ubuntu One', |
97 | + 'Shared With Me') |
98 | + old_path = os.path.join(old_shares_path, 'share1_name') |
99 | + os.symlink(self.shares_dir, old_shares_path) |
100 | + |
101 | + # put the old path in the mdobj |
102 | + share_md = self.fsm.fs[share_mdid] |
103 | + share_md['path'] = old_path |
104 | + self.fsm.fs[share_mdid] = share_md |
105 | |
106 | # break the node on purpose, with hashes in None |
107 | real_mdobj = self.fsm.fs[mdid] |
108 | @@ -312,14 +363,67 @@ |
109 | # start up again, and check |
110 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
111 | md_version = open(version_file).read() |
112 | - self.assertEqual(md_version, "3") |
113 | + self.assertEqual(md_version, "4") |
114 | newmdobj = newfsm.get_by_path(path) |
115 | self.assertEqual(newmdobj.mdid, mdid) |
116 | self.assertEqual(newmdobj.local_hash, "") |
117 | self.assertEqual(newmdobj.server_hash, "") |
118 | self.assertTrue(isinstance(newmdobj.path, str)) |
119 | # pylint: disable-msg=W0212 |
120 | - self.assertEqual(1, len(newfsm._idx_node_id)) |
121 | + self.assertEqual(2, len(newfsm._idx_node_id)) |
122 | + self.assertTrue(other_share.path in newfsm._idx_path) |
123 | + self.assertFalse(old_path in newfsm._idx_path) |
124 | + |
125 | + def test_old_metadata_3(self): |
126 | + '''Faking an old metadata situation, in v3.''' |
127 | + # create a path with the old layout and metadata |
128 | + # the root |
129 | + root_mdid = self.fsm.create(self.root_dir, "") |
130 | + self.fsm.set_node_id(self.root_dir, "uuid") |
131 | + # a share |
132 | + other_share = self.create_share('share1', 'share1_name', |
133 | + self.fsm, self.shares_dir) |
134 | + share_mdid = self.fsm.create(other_share.path, "share1") |
135 | + self.fsm.set_node_id(other_share.path, "uuid1") |
136 | + os.makedirs(os.path.join(self.root_dir, 'Ubuntu One')) |
137 | + old_shares_path = os.path.join(self.root_dir, 'Ubuntu One', |
138 | + 'Shared With Me') |
139 | + old_path = os.path.join(old_shares_path, 'share1_name') |
140 | + os.symlink(self.shares_dir, old_shares_path) |
141 | + old_root_path = os.path.join(os.path.dirname(self.root_dir), |
142 | + 'Ubuntu One', 'My Files') |
143 | + |
144 | + # put the old path in the mdobjs |
145 | + share_md = self.fsm.fs[share_mdid] |
146 | + share_md['path'] = old_path |
147 | + self.fsm.fs[share_mdid] = share_md |
148 | + root_md = self.fsm.fs[root_mdid] |
149 | + root_md['path'] = old_root_path |
150 | + self.fsm.fs[root_mdid] = root_md |
151 | + |
152 | + # put the version file in 1 |
153 | + version_file = os.path.join(self.fsmdir, "metadata_version") |
154 | + with open(version_file, "w") as fh: |
155 | + fh.write("3") |
156 | + |
157 | + # start up again, and check |
158 | + newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
159 | + md_version = open(version_file).read() |
160 | + self.assertEqual(md_version, "4") |
161 | + newmdobj = newfsm.get_by_path(other_share.path) |
162 | + self.assertEquals(newmdobj.mdid, share_md['mdid']) |
163 | + self.assertNotEquals(newmdobj.path, share_md['path']) |
164 | + |
165 | + root_dir = os.path.dirname(old_root_path) |
166 | + rootmdobj = newfsm.get_by_path(root_dir) |
167 | + self.assertEquals(rootmdobj.mdid, root_md['mdid']) |
168 | + self.assertEquals(rootmdobj.path, root_dir) |
169 | + # pylint: disable-msg=W0212 |
170 | + self.assertEqual(2, len(newfsm._idx_node_id)) |
171 | + self.assertTrue(other_share.path in newfsm._idx_path) |
172 | + self.assertFalse(old_path in newfsm._idx_path) |
173 | + self.assertTrue(root_dir in newfsm._idx_path) |
174 | + self.assertFalse(old_root_path in newfsm._idx_path) |
175 | |
176 | def test_fresh_metadata_broken_pickle_without_backup(self): |
177 | '''Initing with latest metadata, but with broked value in the shelf''' |
178 | @@ -347,7 +451,7 @@ |
179 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
180 | version_file = os.path.join(self.fsmdir, "metadata_version") |
181 | md_version = open(version_file).read() |
182 | - self.assertEqual(md_version, "3") |
183 | + self.assertEqual(md_version, "4") |
184 | self.assertTrue(newfsm.get_by_mdid(mdid) is not None) |
185 | self.assertRaises(KeyError, newfsm.get_by_mdid, mdid1) |
186 | self.assertRaises(KeyError, newfsm.get_by_mdid, mdid2) |
187 | @@ -382,7 +486,7 @@ |
188 | # start up again, and check |
189 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
190 | md_version = open(version_file).read() |
191 | - self.assertEqual(md_version, "3") |
192 | + self.assertEqual(md_version, "4") |
193 | self.assertTrue(newfsm.get_by_mdid(mdid) is not None) |
194 | self.assertRaises(KeyError, newfsm.get_by_mdid, mdid1) |
195 | self.assertRaises(KeyError, newfsm.get_by_mdid, mdid2) |
196 | @@ -421,7 +525,7 @@ |
197 | # start up again, and check |
198 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
199 | md_version = open(version_file).read() |
200 | - self.assertEqual(md_version, "3") |
201 | + self.assertEqual(md_version, "4") |
202 | newmdobj = newfsm.get_by_path(path) |
203 | self.assertEqual(newmdobj.mdid, mdid) |
204 | self.assertEqual(newmdobj.local_hash, "") |
205 | @@ -465,7 +569,7 @@ |
206 | # start up again, and check |
207 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
208 | md_version = open(version_file).read() |
209 | - self.assertEqual(md_version, "3") |
210 | + self.assertEqual(md_version, "4") |
211 | newmdobj = newfsm.get_by_path(path) |
212 | self.assertEqual(newmdobj.mdid, mdid) |
213 | self.assertEqual(newmdobj.local_hash, "") |
214 | @@ -505,7 +609,7 @@ |
215 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
216 | version_file = os.path.join(self.fsmdir, "metadata_version") |
217 | md_version = open(version_file).read() |
218 | - self.assertEqual(md_version, "3") |
219 | + self.assertEqual(md_version, "4") |
220 | self.assertTrue(newfsm.get_by_mdid(mdid) is not None) |
221 | # pylint: disable-msg=W0212 |
222 | self.assertEqual(1, len(newfsm._idx_node_id)) |
223 | @@ -547,7 +651,7 @@ |
224 | # start up again, and check |
225 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
226 | md_version = open(version_file).read() |
227 | - self.assertEqual(md_version, "3") |
228 | + self.assertEqual(md_version, "4") |
229 | self.assertTrue(newfsm.get_by_mdid(mdid) is not None) |
230 | # pylint: disable-msg=W0212 |
231 | self.assertEqual(1, len(newfsm._idx_node_id)) |
232 | @@ -593,7 +697,7 @@ |
233 | # start up again, and check |
234 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
235 | md_version = open(version_file).read() |
236 | - self.assertEqual(md_version, "3") |
237 | + self.assertEqual(md_version, "4") |
238 | newmdobj = newfsm.get_by_path(path) |
239 | self.assertEqual(newmdobj.mdid, mdid) |
240 | self.assertEqual(newmdobj.local_hash, "") |
241 | @@ -645,7 +749,7 @@ |
242 | # start up again, and check |
243 | newfsm = FileSystemManager(self.fsmdir, self.fsm.vm) |
244 | md_version = open(version_file).read() |
245 | - self.assertEqual(md_version, "3") |
246 | + self.assertEqual(md_version, "4") |
247 | newmdobj = newfsm.get_by_path(path) |
248 | self.assertEqual(newmdobj.mdid, mdid) |
249 | self.assertEqual(newmdobj.local_hash, "") |
250 | |
251 | === modified file 'ubuntuone/syncdaemon/filesystem_manager.py' |
252 | --- ubuntuone/syncdaemon/filesystem_manager.py 2009-08-21 20:07:08 +0000 |
253 | +++ ubuntuone/syncdaemon/filesystem_manager.py 2009-08-27 19:57:42 +0000 |
254 | @@ -31,7 +31,7 @@ |
255 | from ubuntuone.syncdaemon import file_shelf |
256 | import uuid |
257 | |
258 | -METADATA_VERSION = "3" |
259 | +METADATA_VERSION = "4" |
260 | |
261 | # |
262 | # File System Manager (FSM) |
263 | @@ -241,6 +241,18 @@ |
264 | # filter all False values |
265 | return itertools.ifilter(None, safe_iteritems) |
266 | |
267 | + def _fix_path_for_new_layout(self, mdobj): |
268 | + """fix the mdobj path for the new layout, only for shares root""" |
269 | + base_path, name = os.path.split(mdobj['path']) |
270 | + if base_path.startswith('/') and \ |
271 | + base_path.endswith('Ubuntu One/Shared With Me'): |
272 | + realpath = os.path.realpath(mdobj['path']) |
273 | + mdobj['path'] = realpath |
274 | + if base_path.startswith('/') and \ |
275 | + base_path.endswith('Ubuntu One') and name == 'My Files': |
276 | + mdobj['path'] = base_path |
277 | + |
278 | + |
279 | def _load_metadata_None(self, old_version): |
280 | '''Loads metadata from when it wasn't even versioned.''' |
281 | logger("loading metadata from old version %r", old_version) |
282 | @@ -254,8 +266,10 @@ |
283 | del self.fs[mdid] |
284 | continue |
285 | |
286 | + # fix the path |
287 | + self._fix_path_for_new_layout(mdobj) |
288 | + abspath = self.get_abspath(mdobj["share_id"], mdobj["path"]) |
289 | # of course, load the metadata |
290 | - abspath = self.get_abspath(mdobj["share_id"], mdobj["path"]) |
291 | self._idx_path[abspath] = mdid |
292 | if mdobj["node_id"] is not None: |
293 | self._idx_node_id[(mdobj["share_id"], mdobj["node_id"])] = mdid |
294 | @@ -295,6 +309,8 @@ |
295 | if mdobj["server_hash"] is None: |
296 | mdobj["server_hash"] = "" |
297 | |
298 | + # fix the path |
299 | + self._fix_path_for_new_layout(mdobj) |
300 | # write back the object |
301 | self.fs[mdid] = mdobj |
302 | |
303 | @@ -319,9 +335,30 @@ |
304 | if mdobj["server_hash"] is None: |
305 | mdobj["server_hash"] = "" |
306 | |
307 | - # write back the object |
308 | - self.fs[mdid] = mdobj |
309 | - |
310 | + # fix the path |
311 | + self._fix_path_for_new_layout(mdobj) |
312 | + # write back the object |
313 | + self.fs[mdid] = mdobj |
314 | + |
315 | + # and of course, load the metadata |
316 | + abspath = self.get_abspath(mdobj["share_id"], mdobj["path"]) |
317 | + self._idx_path[abspath] = mdid |
318 | + if mdobj["node_id"] is not None: |
319 | + self._idx_node_id[(mdobj["share_id"], mdobj["node_id"])] = mdid |
320 | + |
321 | + # set new version |
322 | + with open(self._version_file, "w") as fh: |
323 | + fh.write(METADATA_VERSION) |
324 | + |
325 | + def _load_metadata_3(self, old_version): |
326 | + '''Loads metadata from version 3.''' |
327 | + logger("loading metadata from old version %r", old_version) |
328 | + |
329 | + for mdid, mdobj in self._safe_fs_iteritems(): |
330 | + # fix the path |
331 | + self._fix_path_for_new_layout(mdobj) |
332 | + # write back the object |
333 | + self.fs[mdid] = mdobj |
334 | # and of course, load the metadata |
335 | abspath = self.get_abspath(mdobj["share_id"], mdobj["path"]) |
336 | self._idx_path[abspath] = mdid |
Fix the FSM metadata for the new layout.
Basically this updates the path of the shares in the fsm metadata as we store the full path for the share root (shares inclues the users root)