Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/jarabe/journal/misc.py
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-04 10:47:49 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-04 10:47:49 (GMT)
commit7143d9c7de17aa12bd6a6de2f857061dcc04f137 (patch)
tree69cd9e48ffb000024e36f21ac2f59d8b3a942efe /src/jarabe/journal/misc.py
parent226fecd53461db6c1188deb80dedd9cc5a05e353 (diff)
#165 Install bundles when they get into the journal
Diffstat (limited to 'src/jarabe/journal/misc.py')
-rw-r--r--src/jarabe/journal/misc.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py
index 729960b..581b2e2 100644
--- a/src/jarabe/journal/misc.py
+++ b/src/jarabe/journal/misc.py
@@ -87,12 +87,25 @@ def get_date(metadata):
def get_bundle(metadata):
try:
- file_path = util.TempFilePath(model.get_file(metadata['uid']))
- if is_activity_bundle(metadata) and os.path.exists(file_path):
+ if is_activity_bundle(metadata):
+ file_path = util.TempFilePath(model.get_file(metadata['uid']))
+ if not os.path.exists(file_path):
+ logging.warning('Invalid path: %r' % file_path)
+ return None
return ActivityBundle(file_path)
- elif is_content_bundle(metadata) and os.path.exists(file_path):
+
+ elif is_content_bundle(metadata):
+ file_path = util.TempFilePath(model.get_file(metadata['uid']))
+ if not os.path.exists(file_path):
+ logging.warning('Invalid path: %r' % file_path)
+ return None
return ContentBundle(file_path)
- elif is_journal_bundle(metadata) and os.path.exists(file_path):
+
+ elif is_journal_bundle(metadata):
+ file_path = util.TempFilePath(model.get_file(metadata['uid']))
+ if not os.path.exists(file_path):
+ logging.warning('Invalid path: %r' % file_path)
+ return None
return JournalEntryBundle(file_path)
else:
return None
@@ -197,8 +210,8 @@ def resume(metadata, bundle_id=None):
activityfactory.create_with_object_id(bundle, object_id)
def is_activity_bundle(metadata):
- return metadata['mime_type'] in \
- [ActivityBundle.MIME_TYPE, ActivityBundle.DEPRECATED_MIME_TYPE]
+ return metadata['mime_type'] == ActivityBundle.MIME_TYPE or \
+ metadata['mime_type'] == ActivityBundle.DEPRECATED_MIME_TYPE
def is_content_bundle(metadata):
return metadata['mime_type'] == ContentBundle.MIME_TYPE