Merge lp:~verterok/ubuntuone-client/new-layout into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: dobey
Approved revision: 166
Merged at revision: not available
Proposed branch: lp:~verterok/ubuntuone-client/new-layout
Merge into: lp:ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/new-layout
Reviewer Review Type Date Requested Status
dobey (community) Approve
Joshua Blount (community) Approve
Review via email: mp+10465@code.launchpad.net

Commit message

new almost flat layout, remove My Files and use Ubuntu One directory as the root, symlink the Shared with Me folder

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

new layout, finally!

166. By Guillermo Gonzalez

test the conflict case

Revision history for this message
Joshua Blount (jblount) wrote :

Very, very excited about this. Very.

review: Approve
Revision history for this message
dobey (dobey) wrote :

Since you previously changed the applet to set the bookmark to My Files, you'll now have to fix it to migrate the bookmark back to the root instead. :)

review: Needs Fixing
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

> Since you previously changed the applet to set the bookmark to My Files,
> you'll now have to fix it to migrate the bookmark back to the root instead. :)

The change was in the syncdaemon not in the applet, so the applet is stil using the get_root from dbus and should be using the current root ~/Ubuntu One

Revision history for this message
dobey (dobey) wrote :

Ah, right you are.

review: Approve
Revision history for this message
dobey (dobey) wrote :

You need to install gnome-common from the GNOME source repository

Revision history for this message
dobey (dobey) wrote :

/usr/bin/gnome-autogen.sh
checking for autoconf >= 2.53...
(B testing autoconf2.50... not found.
  testing autoconf... found 2.64
checking for automake >= 1.10...
(B testing automake-1.11... found 1.11
checking for libtool >= 1.5...
(B testing libtoolize... found 2.2.6
checking for intltool >= 0.30...
(B testing intltoolize... found 0.40.6
checking for pkg-config >= 0.14.0...
(B testing pkg-config... found 0.22
Checking for required M4 macros...
(BChecking for forbidden M4 macros...
(BProcessing ./configure.ac
(BRunning libtoolize...
(Blibtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
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'
Running intltoolize...
(BRunning aclocal-1.11...
(B
aclocal-1.11: couldn't open directory `/usr/local/share/aclocal': No such file or directory

167. By Guillermo Gonzalez

update old metadata migration tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-syncdaemon'
2--- bin/ubuntuone-syncdaemon 2009-08-18 12:15:49 +0000
3+++ bin/ubuntuone-syncdaemon 2009-08-19 20:32:44 +0000
4@@ -36,7 +36,7 @@
5
6 from configglue import configglue
7 from twisted.internet import reactor
8-from xdg.BaseDirectory import xdg_config_dirs, xdg_cache_home
9+from xdg.BaseDirectory import xdg_config_dirs, xdg_cache_home, xdg_data_home
10
11 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
12
13@@ -48,13 +48,20 @@
14 return os.path.expanduser(value)
15
16
17-def cache_dir_parser(value):
18+def xdg_cache_dir_parser(value):
19 """ Parser for the data_dir option.
20 returns the path using xdg_cache_home + value.
21 """
22 return os.path.join(xdg_cache_home, value)
23
24
25+def xdg_data_dir_parser(value):
26+ """ Parser for the data_dir option.
27+ returns the path using xdg_data_home + value.
28+ """
29+ return os.path.join(xdg_data_home, value)
30+
31+
32 def log_level_parser(value):
33 level = getattr(logging, value, None)
34 if level is None:
35@@ -105,8 +112,9 @@
36 (parser, options, argv) = configglue(file(configs[0]), *configs[1:],
37 args=args, usage=usage,
38 extra_parsers=[('home_dir', home_dir_parser),
39- ('cache_dir', cache_dir_parser),
40- ('log_level', log_level_parser)])
41+ ('xdg_cache', xdg_cache_dir_parser),
42+ ('xdg_data', xdg_data_dir_parser),
43+ ('log_level', log_level_parser)])
44
45 if options.debug:
46 logger.set_debug('stdout file')
47@@ -126,24 +134,15 @@
48 if not os.path.exists(options.data_dir):
49 os.makedirs(options.data_dir)
50
51- if not os.path.exists(options.root_dir):
52- os.makedirs(options.root_dir)
53-
54- user_root_dir = os.path.join(options.root_dir, 'My Files')
55- shares_root_dir = os.path.join(options.root_dir, 'Shared With Me')
56- if not os.path.exists(options.root_dir):
57- os.makedirs(options.root_dir)
58- # make the root read only
59- os.chmod(options.root_dir, 0555)
60-
61- main = Main(user_root_dir, shares_root_dir, options.data_dir,
62+ main = Main(options.root_dir, options.shares_dir, options.data_dir,
63 host=options.host, port=int(options.port),
64 dns_srv=options.dns_srv, ssl=True,
65 disable_ssl_verify=options.disable_ssl_verify,
66 realm=options.realm, mark_interval=options.mark_interval,
67 dbus_events=options.send_events_over_dbus,
68 handshake_timeout=options.handshake_timeout,
69- max_handshake_timeouts=options.max_handshake_timeouts)
70+ max_handshake_timeouts=options.max_handshake_timeouts,
71+ shares_symlink_name='Shared With Me')
72 if options.oauth:
73 try:
74 (key, secret) = options.oauth.split(':', 2)
75
76=== modified file 'contrib/testing/testcase.py'
77--- contrib/testing/testcase.py 2009-08-13 18:06:22 +0000
78+++ contrib/testing/testcase.py 2009-08-19 20:32:44 +0000
79@@ -91,8 +91,7 @@
80 self.root_dir = root_dir
81 self.data_dir = data_dir
82 self.shares_dir = shares_dir
83- self.shares_dir_link = os.path.join(self.root_dir,
84- os.path.basename(self.shares_dir))
85+ self.shares_dir_link = os.path.join(self.root_dir, 'Shared With Me')
86 self.realm = 'http://test.ubuntuone.com'
87 self.oauth_client = FakeOAuthClient(self.realm)
88 self.vm = volume_manager.VolumeManager(self)
89
90=== modified file 'data/syncdaemon.conf'
91--- data/syncdaemon.conf 2009-08-14 18:37:28 +0000
92+++ data/syncdaemon.conf 2009-08-19 20:32:44 +0000
93@@ -18,8 +18,12 @@
94 root_dir.parser = home_dir
95 root_dir.help = Use the specified directory as the root
96
97+shares_dir.default = ubuntuone/shares
98+shares_dir.parser = xdg_data
99+shares_dir.help = Use the specified directory as shares root
100+
101 data_dir.default = ubuntuone/syncdaemon
102-data_dir.parser = cache_dir
103+data_dir.parser = xdg_cache
104 data_dir.help = Use the specified directory to store the metadata
105
106 realm.default = https://ubuntuone.com
107
108=== modified file 'tests/syncdaemon/test_main.py'
109--- tests/syncdaemon/test_main.py 2009-08-18 18:59:35 +0000
110+++ tests/syncdaemon/test_main.py 2009-08-19 20:32:44 +0000
111@@ -166,7 +166,7 @@
112
113 def test_create_dirs_already_exists_dirs(self):
114 """test that creating a Main instance works as expected."""
115- link = os.path.join(self.root, os.path.basename(self.shares))
116+ link = os.path.join(self.root, 'Shared With Me')
117 self.assertFalse(os.path.exists(link))
118 self.assertTrue(os.path.exists(self.shares))
119 self.assertTrue(os.path.exists(self.root))
120@@ -179,7 +179,7 @@
121
122 def test_create_dirs_already_exists_symlink_too(self):
123 """test that creating a Main instance works as expected."""
124- link = os.path.join(self.root, os.path.basename(self.shares))
125+ link = os.path.join(self.root, 'Shared With Me')
126 os.symlink(self.shares, link)
127 self.assertTrue(os.path.exists(link))
128 self.assertTrue(os.path.islink(link))
129@@ -192,7 +192,7 @@
130
131 def test_create_dirs_already_exists_but_not_symlink(self):
132 """test that creating a Main instance works as expected."""
133- link = os.path.join(self.root, os.path.basename(self.shares))
134+ link = os.path.join(self.root, 'Shared With Me')
135 os.makedirs(link)
136 self.assertTrue(os.path.exists(link))
137 self.assertFalse(os.path.islink(link))
138@@ -206,7 +206,7 @@
139
140 def test_create_dirs_none_exists(self):
141 """test that creating a Main instance works as expected."""
142- link = os.path.join(self.root, os.path.basename(self.shares))
143+ link = os.path.join(self.root, 'Shared With Me')
144 # remove the existing dirs
145 os.rmdir(self.root)
146 os.rmdir(self.shares)
147
148=== modified file 'tests/syncdaemon/test_vm.py'
149--- tests/syncdaemon/test_vm.py 2009-08-12 19:49:30 +0000
150+++ tests/syncdaemon/test_vm.py 2009-08-20 16:00:23 +0000
151@@ -592,3 +592,36 @@
152 self.assertEquals(0, len(backup_keys))
153 self.check_version()
154
155+ def test_3_to_4(self):
156+ """upgrade from version 3 to 4"""
157+ vm_data_dir = os.path.join(self.data_dir, 'vm')
158+ os.makedirs(vm_data_dir)
159+ with open(os.path.join(vm_data_dir, '.version'), 'w') as fd:
160+ fd.write('3')
161+ # build the old layout
162+
163+ old_root = os.path.join(self.root_dir, 'My Files')
164+ old_shares = os.path.join(self.root_dir, 'Shared With Me')
165+ os.makedirs(os.path.join(old_root, 'test_dir'))
166+ open(os.path.join(old_root, 'test_file'), 'w').close()
167+ share_path = os.path.join(old_shares, 'Bla from Foo')
168+ os.makedirs(share_path)
169+ os.makedirs(os.path.join(share_path, 'test_dir'))
170+ open(os.path.join(share_path, 'test_file'), 'w').close()
171+ # fix permissions
172+ os.chmod(self.root_dir, 0555)
173+ os.chmod(old_shares, 0555)
174+ # migrate the data
175+ self.main = FakeMain(self.root_dir, self.shares_dir, self.data_dir)
176+ self.assertFalse(os.path.exists(old_root))
177+ self.assertTrue(os.path.exists(old_shares))
178+ self.assertTrue(os.path.islink(old_shares))
179+ self.assertEquals(old_shares, self.main.shares_dir_link)
180+ self.assertTrue(os.path.exists(os.path.join(self.root_dir,
181+ 'test_dir')))
182+ self.assertTrue(os.path.exists(os.path.join(self.root_dir,
183+ 'test_file')))
184+ self.assertTrue(os.path.exists(share_path))
185+ self.assertTrue(os.path.exists(os.path.join(share_path, 'test_dir')))
186+ self.assertTrue(os.path.exists(os.path.join(share_path, 'test_file')))
187+
188
189=== modified file 'ubuntuone/syncdaemon/main.py'
190--- ubuntuone/syncdaemon/main.py 2009-08-18 12:39:53 +0000
191+++ ubuntuone/syncdaemon/main.py 2009-08-19 20:32:44 +0000
192@@ -77,12 +77,12 @@
193 disable_ssl_verify=False,
194 realm='https://ubuntuone.com', glib_loop=False,
195 mark_interval=120, dbus_events=False,
196- handshake_timeout=30, max_handshake_timeouts=10):
197+ handshake_timeout=30, max_handshake_timeouts=10,
198+ shares_symlink_name='Shared With Me'):
199 """ create the instance. """
200 self.root_dir = root_dir
201 self.shares_dir = shares_dir
202- self.shares_dir_link = os.path.join(self.root_dir,
203- os.path.basename(self.shares_dir))
204+ self.shares_dir_link = os.path.join(self.root_dir, shares_symlink_name)
205 self.data_dir = data_dir
206 self.logger = logging.getLogger('ubuntuone.SyncDaemon.Main')
207 self.host = host
208
209=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
210--- ubuntuone/syncdaemon/volume_manager.py 2009-08-17 20:04:08 +0000
211+++ ubuntuone/syncdaemon/volume_manager.py 2009-08-20 16:00:23 +0000
212@@ -89,7 +89,7 @@
213 class VolumeManager(object):
214 """Manages shares and mount points."""
215
216- METADATA_VERSION = '3'
217+ METADATA_VERSION = '4'
218
219 def __init__(self, main):
220 """Create the instance and populate the shares/d attributes
221@@ -115,16 +115,30 @@
222 else:
223 md_version = None
224
225- if not os.path.exists(self._shares_dir):
226- os.makedirs(self._shares_dir)
227- if not os.path.exists(self._shared_dir):
228- os.makedirs(self._shared_dir)
229-
230 # upgrade the metadata
231 if md_version != VolumeManager.METADATA_VERSION:
232 upgrade_method = getattr(self, "_upgrade_metadata_%s" % md_version)
233 upgrade_method(md_version)
234
235+ if not os.path.exists(self._shares_dir):
236+ os.makedirs(self._shares_dir)
237+ if not os.path.exists(self._shared_dir):
238+ os.makedirs(self._shared_dir)
239+
240+ # build the dir layout
241+ # TODO: migrate from old dir layout
242+ if not os.path.exists(self.m.root_dir):
243+ os.makedirs(self.m.root_dir)
244+ if not os.path.exists(self.m.shares_dir):
245+ os.makedirs(self.m.shares_dir)
246+ # create the shares symlink
247+ if not os.path.exists(self.m.shares_dir_link):
248+ os.symlink(self.m.shares_dir, self.m.shares_dir_link)
249+ # make the shares_dir read only
250+ os.chmod(self.m.shares_dir, 0555)
251+ # make the root read write
252+ os.chmod(self.m.root_dir, 0775)
253+
254 self.shares = ShareFileShelf(self._shares_dir)
255 self.shared = ShareFileShelf(self._shared_dir)
256 if self.shares.get('') is None:
257@@ -134,15 +148,6 @@
258 self.root.access_level = 'Modify'
259 self.root.path = self.m.root_dir
260 self.shares[''] = self.root
261- with allow_writes(os.path.dirname(self.m.shares_dir)):
262- if not os.path.exists(self.m.shares_dir):
263- os.makedirs(self.m.shares_dir)
264- # make it read only
265- os.chmod(self.m.shares_dir, 0555)
266- if not os.path.exists(self.m.root_dir):
267- os.makedirs(self.m.root_dir)
268- if not os.path.exists(self.m.shares_dir_link):
269- os.symlink(self.m.shares_dir, self.m.shares_dir_link)
270 self.marker_share_map = {}
271 self.list_shares_retries = 0
272 self.retries_limit = 5
273@@ -449,6 +454,7 @@
274 del sys.modules['canonical.ubuntuone.storage.syncdaemon.volume_manager']
275 # now upgrade to metadata 3
276 self._upgrade_metadata_2(md_version)
277+ self._upgrade_metadata_3(md_version)
278 self._update_metadata_version()
279
280 def _upgrade_metadata_1(self, md_version):
281@@ -499,6 +505,50 @@
282 os.rename(os.path.join(dirpath, name),
283 os.path.join(dirpath, new_name))
284 names[pos] = new_name
285+ self._upgrade_metadata_3(md_version)
286+ self._update_metadata_version()
287+
288+ def _upgrade_metadata_3(self, md_version):
289+ """
290+ Upgrade to version 4 (new layout!)
291+ move "~/Ubuntu One/Shared With" Me to XDG_DATA/ubuntuone/shares
292+ move "~/Ubuntu One/My Files" contents to "~/Ubuntu One"
293+ """
294+ self.log.debug('upgrading from metadata 3 (new layout)')
295+ old_share_dir = os.path.join(self.m.root_dir, 'Shared With Me')
296+ old_root_dir = os.path.join(self.m.root_dir, 'My Files')
297+ # change permissions
298+ os.chmod(self.m.root_dir, 0775)
299+ os.chmod(old_share_dir, 0775)
300+ os.chmod(old_root_dir, 0775)
301+ # update the path's in metadata and move the folder
302+ shares = ShareFileShelf(self._shares_dir)
303+ if not os.path.exists(os.path.dirname(self.m.shares_dir)):
304+ os.makedirs(os.path.dirname(self.m.shares_dir))
305+ shutil.move(old_share_dir, self.m.shares_dir)
306+ for key in shares.keys():
307+ share = shares[key]
308+ old_path = share.path
309+ share.path = share.path.replace(old_share_dir, self.m.shares_dir)
310+ shares[key] = share
311+
312+ shared = ShareFileShelf(self._shared_dir)
313+ for key in shared.keys():
314+ share = shared[key]
315+ share.path = share.path.replace(old_root_dir, self.m.root_dir)
316+ shared[key] = share
317+ # move the My Files contents, taking care of dir/files with the same
318+ # in the new root
319+ if os.path.exists(old_root_dir):
320+ path_join = os.path.join
321+ for relpath in os.listdir(old_root_dir):
322+ old_path = path_join(old_root_dir, relpath)
323+ new_path = path_join(self.m.root_dir, relpath)
324+ if os.path.exists(new_path):
325+ os.rename(new_path, new_path+'.conflict')
326+ shutil.move(old_path, new_path)
327+ os.rmdir(old_root_dir)
328+ # update the .version file
329 self._update_metadata_version()
330
331 def _update_metadata_version(self):
332@@ -507,6 +557,9 @@
333 os.makedirs(os.path.dirname(self._version_file))
334 with open(self._version_file, 'w') as fd:
335 fd.write(VolumeManager.METADATA_VERSION)
336+ # make sure the data get to disk
337+ fd.flush()
338+ os.fsync(fd.fileno())
339
340
341 @contextmanager

Subscribers

People subscribed via source and target branches