Commit 0ac11c83 authored by Thomas Gambier's avatar Thomas Gambier Committed by Thomas Gambier

[runner] support broken symlinks in writeSignatureFile

parent 0177ace5
...@@ -124,9 +124,12 @@ def writeSignatureFile(slappart_signature_method_dict, runner_working_path, sign ...@@ -124,9 +124,12 @@ def writeSignatureFile(slappart_signature_method_dict, runner_working_path, sign
) )
break break
# construct list of file path and remove broken symlink
filepath_list = filter(os.path.isfile, [os.path.join(dirpath, filename) for filename in filename_list])
if signature_process: if signature_process:
(output, error_output) = signature_process.communicate( (output, error_output) = signature_process.communicate(
'\0'.join([os.path.join(dirpath, filename) for filename in filename_list]) '\0'.join(filepath_list)
) )
if signature_process.returncode != 0: if signature_process.returncode != 0:
...@@ -143,10 +146,7 @@ def writeSignatureFile(slappart_signature_method_dict, runner_working_path, sign ...@@ -143,10 +146,7 @@ def writeSignatureFile(slappart_signature_method_dict, runner_working_path, sign
signature_list.extend(output.strip('\n').split('\n')) signature_list.extend(output.strip('\n').split('\n'))
else: else:
signature_list.extend( signature_list.extend(
getSha256Sum([ getSha256Sum(filepath_list)
os.path.join(dirpath, filename)
for filename in filename_list
])
) )
# Write the signatures in file # Write the signatures in file
......
...@@ -180,6 +180,10 @@ class TestRunnerExporter(unittest.TestCase): ...@@ -180,6 +180,10 @@ class TestRunnerExporter(unittest.TestCase):
self._createFile('backup/runner/instance/slappart0/data', 'hello') self._createFile('backup/runner/instance/slappart0/data', 'hello')
self._createFile('backup/runner/instance/slappart1/data', 'world') self._createFile('backup/runner/instance/slappart1/data', 'world')
os.symlink('data', 'backup/runner/instance/slappart0/good_link')
os.symlink(os.path.abspath('backup/runner/instance/slappart0/data'), 'backup/runner/instance/slappart0/good_abs_link')
os.symlink('unexisting_file', 'backup/runner/instance/slappart0/bad_link')
slappart_signature_method_dict = { slappart_signature_method_dict = {
'./instance/slappart1': './instance/slappart1/srv/.backup_identity_script', './instance/slappart1': './instance/slappart1/srv/.backup_identity_script',
} }
...@@ -191,7 +195,10 @@ class TestRunnerExporter(unittest.TestCase): ...@@ -191,7 +195,10 @@ class TestRunnerExporter(unittest.TestCase):
signature_file_content = f.read() signature_file_content = f.read()
# Slappart1 is using md5sum as signature, others are using sha256sum (default) # Slappart1 is using md5sum as signature, others are using sha256sum (default)
self.assertEqual(signature_file_content, """2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 ./runner/instance/slappart0/data self.assertEqual(signature_file_content,
"""2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 ./runner/instance/slappart0/data
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 ./runner/instance/slappart0/good_abs_link
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 ./runner/instance/slappart0/good_link
49b74873d57ff0307b7c9364e2fe2a3876d8722fbe7ce3a6f1438d47647a86f4 ./etc/.project 49b74873d57ff0307b7c9364e2fe2a3876d8722fbe7ce3a6f1438d47647a86f4 ./etc/.project
7d793037a0760186574b0282f2f435e7 ./runner/instance/slappart1/data""") 7d793037a0760186574b0282f2f435e7 ./runner/instance/slappart1/data""")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment