From 369ae7f7acf8247f17679b57909f525fe3428375 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Sat, 19 Sep 2009 17:28:36 +0000
Subject: Do not fail if activity mime_type was already installed #1394
---
src/sugar/bundle/activitybundle.py | 25 ++++++++++++++++---------
1 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py
index 8aa8fb0..b36ac04 100644
a
|
b
|
class ActivityBundle(Bundle): |
345 | 345 | os.makedirs(mime_pkg_dir) |
346 | 346 | installed_mime_path = os.path.join(mime_pkg_dir, |
347 | 347 | '%s.xml' % self._bundle_id) |
348 | | os.symlink(mime_path, installed_mime_path) |
| 348 | self._symlink(mime_path, installed_mime_path) |
349 | 349 | os.spawnlp(os.P_WAIT, 'update-mime-database', |
350 | 350 | 'update-mime-database', mime_dir) |
351 | 351 | |
… |
… |
class ActivityBundle(Bundle): |
361 | 361 | mime_type.replace('/', '-')) |
362 | 362 | svg_file = mime_icon_base + '.svg' |
363 | 363 | info_file = mime_icon_base + '.icon' |
364 | | if os.path.isfile(svg_file): |
365 | | os.symlink(svg_file, |
366 | | os.path.join(installed_icons_dir, |
367 | | os.path.basename(svg_file))) |
368 | | if os.path.isfile(info_file): |
369 | | os.symlink(info_file, |
370 | | os.path.join(installed_icons_dir, |
371 | | os.path.basename(info_file))) |
| 364 | self._symlink(svg_file, |
| 365 | os.path.join(installed_icons_dir, |
| 366 | os.path.basename(svg_file))) |
| 367 | self._symlink(info_file, |
| 368 | os.path.join(installed_icons_dir, |
| 369 | os.path.basename(info_file))) |
| 370 | |
| 371 | def _symlink(self, src, dst): |
| 372 | if not os.path.isfile(src): |
| 373 | return |
| 374 | logging.debug('Link resource %s to %s', src, dst) |
| 375 | if os.path.exists(dst): |
| 376 | logging.debug('Rewrite %s', dst) |
| 377 | os.unlink(dst) |
| 378 | os.symlink(src, dst) |
372 | 379 | |
373 | 380 | def uninstall(self, install_path, force=False): |
374 | 381 | if os.path.islink(install_path): |