diff options
author | Andrés Ambrois <andresambrois@gmail.com> | 2010-08-24 03:54:59 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2010-08-24 16:01:47 (GMT) |
commit | 089ba387eafec10734ce3023665a163c531b82b4 (patch) | |
tree | c4c04e14b7c72ea35793d4ca818cbe050b8fb2a9 /src/carquinyol/datastore.py | |
parent | 0c3d1b3aaeb0ca69693aa325e32e143a9fae047f (diff) |
Add filesize property to the index.
Don't fail indexing if filesize is missing.
Diffstat (limited to 'src/carquinyol/datastore.py')
-rw-r--r-- | src/carquinyol/datastore.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/carquinyol/datastore.py b/src/carquinyol/datastore.py index 82a6207..44df5a2 100644 --- a/src/carquinyol/datastore.py +++ b/src/carquinyol/datastore.py @@ -159,6 +159,12 @@ class DataStore(dbus.service.Object): if not props.get('timestamp', ''): props['timestamp'] = int(time.time()) + if os.path.exists(file_path): + stat = os.stat(file_path) + props['filesize'] = stat.st_size + else: + props['filesize'] = 0 + self._metadata_store.store(uid, props) self._index_store.store(uid, props) self._file_store.store(uid, file_path, transfer_ownership, @@ -195,6 +201,12 @@ class DataStore(dbus.service.Object): if not props.get('timestamp', ''): props['timestamp'] = int(time.time()) + if os.path.exists(file_path): + stat = os.stat(file_path) + props['filesize'] = stat.st_size + else: + props['filesize'] = 0 + self._metadata_store.store(uid, props) self._index_store.store(uid, props) |