screwdriver-api 7.0.214 → 7.0.215

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "7.0.214",
3
+ "version": "7.0.215",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -78,6 +78,10 @@ Arguments:
78
78
 
79
79
  `GET /builds/{id}/artifacts/{name*}?type=preview`
80
80
 
81
+ `GET /builds/{id}/artifacts/this/is/a/directory/path/?type=download`
82
+
83
+ *Note: To download a directory, there must be a trailing slash (`/`) in the name and `type=download`.*
84
+
81
85
  #### Get build statuses
82
86
  `GET /builds/statuses`
83
87
 
@@ -50,7 +50,10 @@ module.exports = config => ({
50
50
  .then(async () => {
51
51
  // Directory should fetch manifest and
52
52
  // gather all files that belong to that directory
53
- if (artifact.endsWith('/')) {
53
+ if (artifact.endsWith('/') && req.query.type === 'download') {
54
+ // Create a zip name from the directory structure
55
+ const zipName = artifact.split('/').slice(-2)[0];
56
+
54
57
  try {
55
58
  const token = jwt.sign({
56
59
  buildId, artifact, scope: ['user']
@@ -97,17 +100,16 @@ module.exports = config => ({
97
100
  archive.emit('error', err); // Emit error to stop the archive process
98
101
  });
99
102
 
100
- // Append the file stream to the archive
101
- archive.append(fileStream, { name: file });
103
+ const relativePath = file.replace(`./${artifact}`, `./${zipName}/`);
104
+
105
+ // Append the file stream to the archive with the correct relative path
106
+ archive.append(fileStream, { name: relativePath });
102
107
  }
103
108
  }
104
109
 
105
110
  // Finalize the archive once all files are appended
106
111
  archive.finalize();
107
112
 
108
- // Create a zip name from the directory structure
109
- const zipName = artifact.split('/').slice(-2)[0];
110
-
111
113
  // Respond with the PassThrough stream (which is readable by Hapi)
112
114
  return h.response(passThrough)
113
115
  .type('application/zip')