Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidejouer/tools/storage.py
diff options
context:
space:
mode:
Diffstat (limited to 'atoidejouer/tools/storage.py')
-rw-r--r--atoidejouer/tools/storage.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/atoidejouer/tools/storage.py b/atoidejouer/tools/storage.py
index 59e1e79..834ed46 100644
--- a/atoidejouer/tools/storage.py
+++ b/atoidejouer/tools/storage.py
@@ -245,8 +245,13 @@ def png_from_pixbuf(filename, timestamp):
def journal_query(query):
if not datastore:
return
- # find in ds
- _results, _count = datastore.find(query, sorting='timestamp')
+ try:
+ _results, _count = datastore.find(query, sorting='timestamp')
+ except Exception, e:
+ # Oops
+ logger.debug('[tools.storage] journal_query - e: %s' % e)
+ # break
+ _results = []
for _r in _results:
if 'title' in query\
and query['title'] != str(_r.metadata['title']):
@@ -407,12 +412,13 @@ def __check_file_in_journal(sub_path, file_name, mime_type=None):
return
# is already in the journal
elif is_in_journal(file_name, mime_type):
- pass
+ return True
else:
# file path
_path = os.path.join(BUND, 'static', 'ext', sub_path, file_name)
# ensure dir exist in bundle
add_file_to_journal(file_name, _path, mime_type)
+ return False
def __check_dir_files(sub_path, mime_type=None, in_journal=False):
@@ -421,17 +427,19 @@ def __check_dir_files(sub_path, mime_type=None, in_journal=False):
# file by file
for _f in os.listdir(_path):
if in_journal is True:
- __check_file_in_journal(sub_path, _f, mime_type=mime_type)
+ if __check_file_in_journal(sub_path, _f, mime_type=mime_type):
+ return True
else:
__check_file_in_bundle(sub_path, _f)
+ return False
def init_activity_files():
- __check_dir_files('db')
- __check_dir_files('stories')
- # add embedded resources to the journal for common usage
- __check_dir_files('graphics', mime_type='image/png', in_journal=True)
- __check_dir_files('sounds', mime_type='audio/ogg', in_journal=True)
+ # add embedded resources to the journal for common usage (if not already loaded)
+ if not __check_dir_files('graphics', mime_type='image/png', in_journal=True):
+ __check_dir_files('sounds', mime_type='audio/ogg', in_journal=True)
+ # ..
+ # __check_dir_files('db', mime_type='atoidejouer/db', in_journal=True)
def __show_in_out_result_message(label, message):