mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-03-16 22:20:31 +00:00
Minor tweak to cleanup. Using shutil instead of iterating file objects
This commit is contained in:
parent
8e5fcfafed
commit
a6a1859029
2 changed files with 5 additions and 11 deletions
|
|
@ -17,6 +17,7 @@
|
|||
import cPickle as pickle
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
import xapian
|
||||
|
||||
from django.conf import settings
|
||||
|
|
@ -70,13 +71,8 @@ class XapianSearchBackendTestCase(TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
if os.path.exists(settings.HAYSTACK_XAPIAN_PATH):
|
||||
index_files = os.listdir(settings.HAYSTACK_XAPIAN_PATH)
|
||||
|
||||
for index_file in index_files:
|
||||
os.remove(os.path.join(settings.HAYSTACK_XAPIAN_PATH, index_file))
|
||||
|
||||
os.removedirs(settings.HAYSTACK_XAPIAN_PATH)
|
||||
|
||||
shutil.rmtree(settings.HAYSTACK_XAPIAN_PATH)
|
||||
|
||||
settings.HAYSTACK_XAPIAN_PATH = self.old_xapian_path
|
||||
super(XapianSearchBackendTestCase, self).tearDown()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import datetime
|
|||
import cPickle as pickle
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import warnings
|
||||
|
||||
from django.conf import settings
|
||||
|
|
@ -350,10 +351,7 @@ class SearchBackend(BaseSearchBackend):
|
|||
This removes all indexes files and the `HAYSTACK_XAPIAN_PATH` folder.
|
||||
"""
|
||||
if os.path.exists(settings.HAYSTACK_XAPIAN_PATH):
|
||||
index_files = os.listdir(settings.HAYSTACK_XAPIAN_PATH)
|
||||
for index_file in index_files:
|
||||
os.remove(os.path.join(settings.HAYSTACK_XAPIAN_PATH, index_file))
|
||||
os.removedirs(settings.HAYSTACK_XAPIAN_PATH)
|
||||
shutil.rmtree(settings.HAYSTACK_XAPIAN_PATH)
|
||||
|
||||
def document_count(self):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue