diff --git a/lib/cdist/context.py b/lib/cdist/context.py index ed1fd31d..cf314409 100644 --- a/lib/cdist/context.py +++ b/lib/cdist/context.py @@ -41,8 +41,6 @@ class Context(object): debug=False): self.debug = debug - if self.debug: - os.environ['__debug'] = 'yes' self.target_host = target_host diff --git a/lib/cdist/core/explorer.py b/lib/cdist/core/explorer.py index 14a66ff4..90201072 100644 --- a/lib/cdist/core/explorer.py +++ b/lib/cdist/core/explorer.py @@ -105,10 +105,14 @@ class Explorer(object): def transfer_type_explorers(self, cdist_type): """Transfer the type explorers for the given type to the remote side.""" if cdist_type.explorers: - source = os.path.join(self.local.type_path, cdist_type.explorer_path) - destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) - self.remote.mkdir(destination) - self.remote.transfer(source, destination) + if cdist_type.explorers_transferred: + log.debug("Skipping retransfer of type explorers for: %s", cdist_type) + else: + source = os.path.join(self.local.type_path, cdist_type.explorer_path) + destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) + self.remote.mkdir(destination) + self.remote.transfer(source, destination) + cdist_type.explorers_transferred = True def transfer_object_parameters(self, cdist_object): """Transfer the parameters for the given object to the remote side.""" diff --git a/lib/cdist/core/type.py b/lib/cdist/core/type.py index 8cf21ce7..6c3cd757 100644 --- a/lib/cdist/core/type.py +++ b/lib/cdist/core/type.py @@ -67,7 +67,7 @@ class Type(object): self.gencode_remote_path = os.path.join(self.name, "gencode-remote") self.manifest_path = os.path.join(self.name, "manifest") - self.transferred_explorers = False + self.explorers_transferred = False self.__explorers = None self.__required_parameters = None diff --git a/lib/cdist/test/explorer/__init__.py b/lib/cdist/test/explorer/__init__.py index a3a0c9f8..e6858812 100644 --- a/lib/cdist/test/explorer/__init__.py +++ b/lib/cdist/test/explorer/__init__.py @@ -95,6 +95,20 @@ class ExplorerClassTestCase(unittest.TestCase): destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) self.assertEqual(os.listdir(source), os.listdir(destination)) + def test_transfer_type_explorers_only_once(self): + cdist_type = core.Type(self.local.type_path, '__test_type') + # first transfer + self.explorer.transfer_type_explorers(cdist_type) + source = os.path.join(self.local.type_path, cdist_type.explorer_path) + destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) + self.assertEqual(os.listdir(source), os.listdir(destination)) + # nuke destination folder content, but recreate directory + shutil.rmtree(destination) + os.makedirs(destination) + # second transfer, should not happen + self.explorer.transfer_type_explorers(cdist_type) + self.assertFalse(os.listdir(destination)) + def test_transfer_object_parameters(self): cdist_type = core.Type(self.local.type_path, '__test_type') cdist_object = core.Object(cdist_type, self.local.object_path, 'whatever')