Permalink
Browse files

Don't open a writable database in clear method if we're going to rmtr…

…ee. Only do so when required. Should fix issue GH-96.
  • Loading branch information...
1 parent a4281e7 commit 37add92bc43fe50bf165e91f370269c26272f1eb @notanumber committed Jun 5, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 xapian_backend.py
View
@@ -303,20 +303,20 @@ def clear(self, models=[]):
the term `XCONTENTTYPE<app_name>.<model_name>`. This will delete
all documents with the specified model type.
"""
- database = self._database(writable=True)
if not models:
# Because there does not appear to be a "clear all" method,
# it's much quicker to remove the contents of the `self.path`
# folder than it is to remove each document one at a time.
if os.path.exists(self.path):
shutil.rmtree(self.path)
else:
+ database = self._database(writable=True)
for model in models:
database.delete_document(
DOCUMENT_CT_TERM_PREFIX + '%s.%s' %
(model._meta.app_label, model._meta.module_name)
)
- database.close()
+ database.close()
def document_count(self):
try:

0 comments on commit 37add92

Please sign in to comment.