diff options
author | Andrés Ambrois <andresambrois@gmail.com> | 2010-05-23 12:04:10 (GMT) |
---|---|---|
committer | Michael Stone <michael@laptop.org> | 2010-06-24 21:03:27 (GMT) |
commit | 631ab6fa6255c3d9ce8fae65cdf2fe57fe02dc76 (patch) | |
tree | d30e5c98a3f03874938ff613de5b43b9d48be476 | |
parent | 589d3fcd0766449c166ad00e5d4d1f1778f19352 (diff) |
Add ctime property to the index and datastore
Signed-off-by: Andrés Ambrois <andresambrois@gmail.com>
Signed-off-by: Michael Stone <michael@laptop.org>
-rw-r--r-- | datastore/src/carquinyol/datastore.py | 10 | ||||
-rw-r--r-- | datastore/src/carquinyol/indexstore.py | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/datastore/src/carquinyol/datastore.py b/datastore/src/carquinyol/datastore.py index 5d49e42..28ac800 100644 --- a/datastore/src/carquinyol/datastore.py +++ b/datastore/src/carquinyol/datastore.py @@ -131,8 +131,11 @@ class DataStore(dbus.service.Object): async_cb, async_err_cb): uid = str(uuid.uuid4()) + ctime = int(time.time()) if not props.get('timestamp', ''): - props['timestamp'] = int(time.time()) + props['timestamp'] = ctime + if not props.get('ctime', ''): + props['ctime'] = ctime if os.path.exists(file_path): stat = os.stat(file_path) @@ -168,8 +171,11 @@ class DataStore(dbus.service.Object): byte_arrays=True) def update(self, uid, props, file_path, transfer_ownership, async_cb, async_err_cb): + timestamp = int(time.time()) + if not props.get('ctime', ''): + props['ctime'] = props.get('timestamp', timestamp) if not props.get('timestamp', ''): - props['timestamp'] = int(time.time()) + props['timestamp'] = timestamp if os.path.exists(file_path): stat = os.stat(file_path) diff --git a/datastore/src/carquinyol/indexstore.py b/datastore/src/carquinyol/indexstore.py index 8223301..88d12d5 100644 --- a/datastore/src/carquinyol/indexstore.py +++ b/datastore/src/carquinyol/indexstore.py @@ -60,6 +60,7 @@ _QUERY_TERM_MAP = { _QUERY_VALUE_MAP = { 'timestamp': {'number': _VALUE_TIMESTAMP, 'type': float}, 'filesize': {'number': _VALUE_FILESIZE, 'type': int}, + 'ctime': {'number': _VALUE_CTIME, 'type': int}, } @@ -71,6 +72,8 @@ class TermGenerator (xapian.TermGenerator): document.add_value(_VALUE_TITLE, properties.get('title', '').strip()) document.add_value(_VALUE_FILESIZE, xapian.sortable_serialise(int(properties['filesize']))) + document.add_value(_VALUE_CTIME, + xapian.sortable_serialise(int(properties['ctime']))) self.set_document(document) @@ -283,6 +286,10 @@ class IndexStore(object): enquire.set_sort_by_value(_VALUE_TIMESTAMP, True) elif order_by == '-timestamp': enquire.set_sort_by_value(_VALUE_TIMESTAMP, False) + elif order_by == '+ctime': + enquire.set_sort_by_value(_VALUE_CTIME, True) + elif order_by == '-ctime': + enquire.set_sort_by_value(_VALUE_CTIME, False) elif order_by == '+title': enquire.set_sort_by_value(_VALUE_TITLE, True) elif order_by == '-title': |