summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/adapter/search/__init__.py4
-rw-r--r--service/pixelated/config/services.py5
-rw-r--r--service/test/support/integration/app_test_client.py2
-rw-r--r--service/test/unit/adapter/search/test_search.py8
4 files changed, 11 insertions, 8 deletions
diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py
index 27563c03..dbd4d288 100644
--- a/service/pixelated/adapter/search/__init__.py
+++ b/service/pixelated/adapter/search/__init__.py
@@ -36,9 +36,9 @@ class SearchEngine(object):
DEFAULT_INDEX_HOME = os.path.join(os.environ['HOME'], '.leap')
DEFAULT_TAGS = ['inbox', 'sent', 'drafts', 'trash']
- def __init__(self, key, namespace, agent_home=DEFAULT_INDEX_HOME):
+ def __init__(self, key, user_home=DEFAULT_INDEX_HOME):
self.key = key
- self.index_folder = os.path.join(agent_home, 'search_index', namespace)
+ self.index_folder = os.path.join(user_home, 'search_index')
if not os.path.exists(self.index_folder):
os.makedirs(self.index_folder)
self._index = self._create_index()
diff --git a/service/pixelated/config/services.py b/service/pixelated/config/services.py
index a55fdfa3..1d5d951a 100644
--- a/service/pixelated/config/services.py
+++ b/service/pixelated/config/services.py
@@ -1,3 +1,4 @@
+import os
import logging
from pixelated.adapter.mailstore.leap_attachment_store import LeapAttachmentStore
@@ -54,7 +55,9 @@ class Services(object):
key_unicode = yield search_index_storage_key.get_or_create_key()
key = str(key_unicode)
logger.debug('The key len is: %s' % len(key))
- search_engine = SearchEngine(key, namespace, agent_home=self._leap_home)
+ user_id = self._leap_session.user_auth.uuid
+ user_folder = os.path.join(self._leap_home, user_id)
+ search_engine = SearchEngine(key, user_home=user_folder)
self.search_engine = search_engine
def _setup_mail_service(self, search_engine):
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index 894aec2d..40c24418 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -67,7 +67,7 @@ class AppTestClient(object):
self.keymanager = mock()
- self.search_engine = SearchEngine(self.INDEX_KEY, 'test_namespace', agent_home=soledad_test_folder)
+ self.search_engine = SearchEngine(self.INDEX_KEY, user_home=soledad_test_folder)
self.mail_sender = self._create_mail_sender()
self.mail_store = SearchableMailStore(LeapMailStore(self.soledad), self.search_engine)
diff --git a/service/test/unit/adapter/search/test_search.py b/service/test/unit/adapter/search/test_search.py
index 654524f5..198a818b 100644
--- a/service/test/unit/adapter/search/test_search.py
+++ b/service/test/unit/adapter/search/test_search.py
@@ -43,14 +43,14 @@ class LockStub(object):
class SearchEngineTest(unittest.TestCase):
def setUp(self):
self.tempdir = TempDir()
- self.agent_home = self.tempdir.name
+ self.user_home = self.tempdir.name
def tearDown(self):
self.tempdir.dissolve()
def test_headers_encoding(self):
# given
- se = SearchEngine(INDEX_KEY, 'test_namespace', self.agent_home)
+ se = SearchEngine(INDEX_KEY, self.user_home)
headers = {
'From': 'foo@bar.tld',
@@ -68,7 +68,7 @@ class SearchEngineTest(unittest.TestCase):
def test_contents_encoding_accents(self):
# given
- se = SearchEngine(INDEX_KEY, 'test_namespace', self.agent_home)
+ se = SearchEngine(INDEX_KEY, self.user_home)
headers = {
'From': 'foo@bar.tld',
@@ -93,7 +93,7 @@ class SearchEngineTest(unittest.TestCase):
def test_contents_encoding_special_characters(self):
# given
- se = SearchEngine(INDEX_KEY, 'test_namespace', self.agent_home)
+ se = SearchEngine(INDEX_KEY, self.user_home)
headers = {
'From': 'foo@bar.tld',