@@ -29,12 +29,16 @@ async function getThumbnail(streamer) {
29
29
const headObjectCommand = new HeadObjectCommand ( { Bucket, Key} ) ;
30
30
const output = await S3_CLIENT . send ( headObjectCommand ) ;
31
31
if ( Date . now ( ) > output . LastModified . getTime ( ) + storage . thumbnails . ttl ) {
32
- return await generateStreamThumbnail ( { streamer, inputURL, Bucket, Key} ) ;
32
+ return await generateStreamThumbnail ( {
33
+ isLive : true , streamer, inputURL, Bucket, Key
34
+ } ) ;
33
35
}
34
36
return resolveObjectURL ( { Bucket, Key} ) ;
35
37
} catch ( err ) {
36
38
if ( err . name === 'NotFound' ) {
37
- return await generateStreamThumbnail ( { streamer, inputURL, Bucket, Key} ) ;
39
+ return await generateStreamThumbnail ( {
40
+ isLive : true , streamer, inputURL, Bucket, Key
41
+ } ) ;
38
42
}
39
43
throw err ;
40
44
} finally {
@@ -43,18 +47,20 @@ async function getThumbnail(streamer) {
43
47
}
44
48
}
45
49
46
- async function generateStreamThumbnail ( { streamer, inputURL, Bucket, Key} ) {
47
- streamer . streamInfo . thumbnailGenerationStatus = ThumbnailGenerationStatus . IN_PROGRESS ;
48
- await streamer . save ( ) ;
49
- await checkFileExists ( inputURL ) ;
50
+ async function generateStreamThumbnail ( { isLive, streamer, inputURL, Bucket, Key} ) {
51
+ if ( isLive ) {
52
+ streamer . streamInfo . thumbnailGenerationStatus = ThumbnailGenerationStatus . IN_PROGRESS ;
53
+ await streamer . save ( ) ;
54
+ await checkFileExists ( inputURL ) ;
55
+ }
50
56
return resolveObjectURL ( await doGenerateStreamThumbnail ( { Bucket, Key, inputURL} ) ) ;
51
57
}
52
58
53
59
async function checkFileExists ( inputURL ) {
54
60
try {
55
61
await axios . head ( inputURL ) ;
56
62
} catch ( err ) {
57
- if ( err . response . status === 404 ) {
63
+ if ( err . response && err . response . status === 404 ) {
58
64
LOGGER . error ( 'Stream file at {} does not exist' , inputURL ) ;
59
65
} else {
60
66
LOGGER . error ( 'An unexpected error occurred during HEAD request to file at {}: {}' , inputURL , err ) ;
0 commit comments