diff --git a/faassupervisor/storage/config.py b/faassupervisor/storage/config.py index c83c610..64ffe42 100644 --- a/faassupervisor/storage/config.py +++ b/faassupervisor/storage/config.py @@ -234,7 +234,7 @@ def upload_output(self, output_dir_path): provider_type = StrUtils.get_storage_type(output['storage_provider']) provider_id = StrUtils.get_storage_id(output['storage_provider']) for file_path in output_files: - file_name = file_path.replace(f'{output_dir_path}/', '').strip() + file_name = file_path.replace(f'{output_dir_path}/', '').strip().lstrip('/') prefix_ok = False suffix_ok = False # Check prefixes diff --git a/test/unit/faassupervisor/storage.py b/test/unit/faassupervisor/storage.py index 7d42832..9b7228d 100644 --- a/test/unit/faassupervisor/storage.py +++ b/test/unit/faassupervisor/storage.py @@ -260,7 +260,7 @@ def test_upload_output(self, mock_minio, mock_s3, mock_get_files): '/tmp/test/result-file.out', '/tmp/test/file2.txt', '/tmp/test/file2.out', - '/tmp/test/\nfile3.out' + '/tmp/test/\n/file3.out' ] mock_get_files.return_value = files StorageConfig().upload_output('/tmp/test') @@ -274,7 +274,7 @@ def test_upload_output(self, mock_minio, mock_s3, mock_get_files): self.assertEqual(mock_s3.call_args_list[i], call(f, f.split('/')[3], 'bucket/folder')) self.assertEqual(mock_s3.call_args_list[6], - call('/tmp/test/\nfile3.out', 'file3.out', 'bucket/folder')) + call('/tmp/test/\n/file3.out', 'file3.out', 'bucket/folder')) # def test_upload_real_output(self): # with mock.patch.dict('os.environ',