File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,11 @@ export class S3 {
5151 * @param string fileName Name of the file without path
5252 * @return string Contains the contents of the file
5353 */
54- public async readS3File ( artifacts_provider : ProviderForPrefix , fileName : string ) {
54+ public async readS3File (
55+ artifacts_provider : ProviderForPrefix ,
56+ fileName : string ,
57+ errorIfNotExists = true
58+ ) {
5559 let fileContents = '' ;
5660 const bucket = AWSVars . artifacts ( ) ;
5761 const filePath = getBasePrefixUrl ( artifacts_provider , 'codebuild-output' ) + '/' + fileName ;
@@ -69,10 +73,12 @@ export class S3 {
6973 // There is not a good way to check for file exists. If file doesn't exist,
7074 // it will be caught here and an empty string returned.
7175 if ( e instanceof NoSuchKey ) {
72- span ?. setStatus ( {
73- code : SpanStatusCode . ERROR ,
74- message : `Error from S3 while getting object "${ filePath } " from "${ bucket } ". No such key exists.`
75- } ) ;
76+ if ( errorIfNotExists ) {
77+ span ?. setStatus ( {
78+ code : SpanStatusCode . ERROR ,
79+ message : `Error from S3 while getting object "${ filePath } " from "${ bucket } ". No such key exists.`
80+ } ) ;
81+ }
7682 } else if ( e instanceof S3ServiceException ) {
7783 span ?. setStatus ( {
7884 code : SpanStatusCode . ERROR ,
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ export async function save(job: Job<BullMQ.S3.CopyArtifacts>): Promise<unknown>
3939 await s3 . copyS3Folder ( build ) ;
4040 let defaultLanguage = await s3 . readS3File ( build , 'play-listing/default-language.txt' ) ;
4141 job . log ( `getExtraContent defaultLanguage: ${ defaultLanguage } ` ) ;
42- const manifestFileContent = await s3 . readS3File ( build , 'manifest.txt' ) ;
42+ const manifestFileContent = await s3 . readS3File ( build , 'manifest.txt' , false ) ;
4343 let manifest : Record < string , string | string [ ] | Record < string , string > > = { } ;
4444 if ( manifestFileContent ) {
4545 const manifestFiles = manifestFileContent . split ( '\n' ) ;
@@ -108,6 +108,8 @@ export async function save(job: Job<BullMQ.S3.CopyArtifacts>): Promise<unknown>
108108 const json = JSON . stringify ( manifest ) ;
109109 const jsonFileName = 'play-listing/manifest.json' ;
110110 await s3 . writeFileToS3 ( json , jsonFileName , build ) ;
111+ } else {
112+ job . log ( 'No manifest found' ) ;
111113 }
112114 await prisma . build . update ( {
113115 where : { id } ,
You can’t perform that action at this time.
0 commit comments