When operating close to ENOSPC, we sometimes end up with
incomplete or invalid on-disk entries. So we prune these
during index rebuild.

Signed-off-by: Martin Langhoff <mar...@laptop.org>
---
 src/carquinyol/datastore.py |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/carquinyol/datastore.py b/src/carquinyol/datastore.py
index 1f098b4..33c658d 100644
--- a/src/carquinyol/datastore.py
+++ b/src/carquinyol/datastore.py
@@ -22,6 +22,7 @@ import logging
 import uuid
 import time
 import os
+import shutil
 
 import dbus
 import dbus.service
@@ -181,6 +182,13 @@ class DataStore(dbus.service.Object):
                     self._index_store.store(uid, props)
                 except Exception:
                     logging.exception('Error processing %r', uid)
+                    logging.warn('Will attempt to delete corrupt entry %r', 
uid)
+                    try:
+                        # self.delete(uid) only works on well-formed entries 
:-/
+                        entry_path = 
layoutmanager.get_instance().get_entry_path(uid)
+                        shutil.rmtree(entry_path)
+                    except Exception:
+                        logging.exception('Error deleting corrupt entry %r', 
uid)
 
         if not uids:
             self._index_store.flush()
-- 
1.7.10.4

_______________________________________________
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel

Reply via email to