summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Wagner <bwgpro@gmail.com>2015-08-07 18:34:12 -0300
committerBruno Wagner <bwgpro@gmail.com>2015-08-12 17:17:19 -0300
commitfa45b38b2cf61d5619e8d9d063fb1a470ab4f086 (patch)
treec7962722102047a82a092a0dce528955021d7082
parent7c1f5e3bcbfd881b6b1b3f258066a13ee7a4839d (diff)
[bug] Encdecpool won't explode if stopped twice
The encryption pool could be stopped twice and would break on the second attempt because it deletes the encryption queue variable. Added a condition to make sure it only deletes the encryption queue if it exists, making it more idempotent
-rw-r--r--client/src/leap/soledad/client/encdecpool.py9
-rw-r--r--common/src/leap/soledad/common/tests/test_sync.py2
-rw-r--r--common/src/leap/soledad/common/tests/test_sync_deferred.py11
3 files changed, 7 insertions, 15 deletions
diff --git a/client/src/leap/soledad/client/encdecpool.py b/client/src/leap/soledad/client/encdecpool.py
index 8713497e..4cdb3cd4 100644
--- a/client/src/leap/soledad/client/encdecpool.py
+++ b/client/src/leap/soledad/client/encdecpool.py
@@ -191,10 +191,11 @@ class SyncEncrypterPool(SyncEncryptDecryptPool):
Stop the encrypter pool.
"""
# close the sync queue
- self._encr_queue.close()
- q = self._encr_queue
- del q
- self._encr_queue = None
+ if self._encr_queue:
+ self._encr_queue.close()
+ q = self._encr_queue
+ del q
+ self._encr_queue = None
SyncEncryptDecryptPool.stop(self)
diff --git a/common/src/leap/soledad/common/tests/test_sync.py b/common/src/leap/soledad/common/tests/test_sync.py
index 128b4287..53dd923b 100644
--- a/common/src/leap/soledad/common/tests/test_sync.py
+++ b/common/src/leap/soledad/common/tests/test_sync.py
@@ -179,8 +179,6 @@ class TestSoledadDbSync(
"""
Need to explicitely invoke inicialization on all bases.
"""
- # tests.TestCaseWithServer.setUp(self)
- # self.main_test_class = test_sync.TestDbSync
SoledadWithCouchServerMixin.setUp(self)
self.startServer()
self.db = self.make_database_for_test(self, 'test1')
diff --git a/common/src/leap/soledad/common/tests/test_sync_deferred.py b/common/src/leap/soledad/common/tests/test_sync_deferred.py
index dcbd16f6..126e9b7b 100644
--- a/common/src/leap/soledad/common/tests/test_sync_deferred.py
+++ b/common/src/leap/soledad/common/tests/test_sync_deferred.py
@@ -34,7 +34,6 @@ from leap.soledad.client.sqlcipher import (
from testscenarios import TestWithScenarios
from leap.soledad.common.tests import u1db_tests as tests
-from leap.soledad.common.tests.u1db_tests import test_sync
from leap.soledad.common.tests.util import ADDRESS
from leap.soledad.common.tests.util import SoledadWithCouchServerMixin
from leap.soledad.common.tests.util import make_soledad_app
@@ -93,10 +92,6 @@ class BaseSoledadDeferredEncTest(SoledadWithCouchServerMixin):
ensure_ddocs=True)
def tearDown(self):
- self.db1.close()
- self.db2.close()
- self._soledad.close()
-
# XXX should not access "private" attrs
shutil.rmtree(os.path.dirname(self._soledad._local_db_path))
SoledadWithCouchServerMixin.tearDown(self)
@@ -112,7 +107,7 @@ class SyncTimeoutError(Exception):
class TestSoledadDbSyncDeferredEncDecr(
TestWithScenarios,
- test_sync.TestDbSync,
+ tests.TestCaseWithServer,
BaseSoledadDeferredEncTest):
"""
@@ -172,15 +167,13 @@ class TestSoledadDbSyncDeferredEncDecr(
self.opts,
crypto,
replica_uid,
+ None,
defer_encryption=True)
self.dbsyncer = dbsyncer
return dbsyncer.sync(
target_url,
creds=creds,
- autocreate=True,
defer_decryption=DEFER_DECRYPTION)
- else:
- return test_sync.TestDbSync.do_sync(self, target_name)
def wait_for_sync(self):
"""