File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -13,21 +13,35 @@ const images = [{
13
13
} , {
14
14
name : '0002.heic' , // single image
15
15
url : drive ( '1J_761fe_HWSijAthq7h_D2Zsf1_es1cT' )
16
+ } , {
17
+ name : '0002-control.png' , // single image control
18
+ url : drive ( '1uomSNTAK5FifvI72lYi6T42zhvVv1LwH' )
16
19
} , {
17
20
name : '0003.heic' , // multiple images
18
21
url : drive ( '1Iru2g084yZGz-eRagiqZgccRJZfGLYgS' )
22
+ } , {
23
+ name : '0003-0-control.png' , // multiple images control, index 0
24
+ url : drive ( '1FZ9mJVj54MpD4c5TMfiOrarzkrT3pr2U' )
25
+ } , {
26
+ name : '0003-1-control.png' , // multiple images control, index 1, 2
27
+ url : drive ( '1qD4-V6FcU2ffpNm0ZxKO2cpqbol73tok' )
19
28
} ] . map ( img => {
20
29
img . path = resolve ( img . name ) ;
21
30
return img ;
22
31
} ) ;
23
32
24
33
( async ( ) => {
25
34
for ( let image of images ) {
35
+ // we won't assume malicious intent... if the images exist, don't bother fetching them
36
+ if ( await fs . exists ( image . path ) ) {
37
+ continue ;
38
+ }
39
+
26
40
const { url, name } = image ;
27
41
const res = await fetch ( url ) ;
28
42
29
43
if ( ! res . ok ) {
30
- throw new Error ( `failed to download ${ name } at ${ url } ` ) ;
44
+ throw new Error ( `failed to download ${ name } at ${ url } : ${ res . status } ${ res . statusText } ` ) ;
31
45
}
32
46
33
47
const buffer = await res . buffer ( ) ;
You can’t perform that action at this time.
0 commit comments