From 54a0d9aab34d5d6ce731a931e6adc165c6191221 Mon Sep 17 00:00:00 2001 Message-Id: <54a0d9aab34d5d6ce731a931e6adc165c6191221.1278225682.git.andresambrois@gmail.com> In-Reply-To: References: From: =?UTF-8?q?Andr=C3=A9s=20Ambrois?= Date: Fri, 2 Jul 2010 03:36:56 -0300 Subject: [PATCH v2 3/7] Check filesize property on index rebuild. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will ensure it gets set when upgrading from older datastores. Signed-off-by: Andrés Ambrois --- src/carquinyol/datastore.py | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/carquinyol/datastore.py b/src/carquinyol/datastore.py index 93ad419..357591f 100644 --- a/src/carquinyol/datastore.py +++ b/src/carquinyol/datastore.py @@ -120,7 +120,15 @@ class DataStore(dbus.service.Object): if not self._index_store.contains(uid): try: + update_metadata = False props = self._metadata_store.retrieve(uid) + if 'filesize' not in props: + path = self._file_store.get_file_path(uid) + if os.path.exists(path): + props['filesize'] = os.stat(path).st_size + update_metadata = True + if update_metadata: + self._metadata_store.store(uid, props) self._index_store.store(uid, props) except Exception: logging.exception('Error processing %r', uid) -- 1.7.0.4