Skip to content

Commit bd8ff2b

Browse files
authored
Paginate images. (#342)
1 parent da9a0b2 commit bd8ff2b

3 files changed

Lines changed: 21 additions & 409 deletions

File tree

data/development-images.json

Lines changed: 1 addition & 397 deletions
Large diffs are not rendered by default.

server/images.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,23 @@ const s3 = new S3({
1616
})
1717

1818
async function downloadImages () {
19-
const manifest = await new Promise((resolve, reject) => {
20-
s3.listObjects({ Bucket: 'elementary-iso' }, (err, data) => {
21-
if (err != null) {
22-
return reject(err)
23-
} else {
24-
return resolve(data)
25-
}
26-
})
27-
})
28-
29-
return manifest.Contents
19+
const allContents = []
20+
let marker = null
21+
22+
do {
23+
const params = { Bucket: 'elementary-iso' }
24+
if (marker) {
25+
params.Marker = marker
26+
}
27+
28+
const data = await s3.listObjects(params)
29+
allContents.push(...data.Contents)
30+
marker = data.IsTruncated
31+
? data.Contents[data.Contents.length - 1].Key
32+
: null
33+
} while (marker)
34+
35+
return allContents
3036
.filter(({ Key }) => Key.endsWith('.iso') || Key.endsWith('.img.xz'))
3137
.map(d => ({
3238
path: d.Key,

store/images.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export const getters = {
66
imagesFor: (state, getters) => (channel = 'daily') => {
77
return getters.images
88
.filter(({ path }) => path.startsWith(`${channel}/`))
9-
.filter(({ path }) => path.includes('7.0') || path.includes('7.1') || path.includes('8.0') || path.includes('8.1'))
9+
// This filter allows us to build dailies for future releases internally before allowing them to be public.
10+
// It only modifies the images shown in the UI, not the actual images that are available for download.
11+
.filter(({ path }) => path.includes('8.0') || path.includes('8.1'))
1012
},
1113

1214
images (state) {

0 commit comments

Comments
 (0)