@@ -14,7 +14,9 @@ const { json } = require('express');
1414const biocontainers = 'https://github.com/BioContainers/containers.git' ;
1515const bioconda = 'https://github.com/bioconda/bioconda-recipes.git' ;
1616
17- var config = yaml_config . load ( 'config.yml' ) ;
17+ const cfgpath = process . env . CONFIG !== undefined ? process . env . CONFIG : 'config.yml' ;
18+
19+ const config = yaml_config . load ( cfgpath ) ;
1820
1921const s3 = new AWS . S3 ( {
2022 endpoint : config . s3 . endpoint ,
@@ -91,7 +93,7 @@ async function send_report() {
9193
9294 let now = Date . now ( ) ;
9395
94- var mailOptions = {
96+ let mailOptions = {
9597 from : config . mail . from ,
9698 to : config . mail . to ,
9799 subject : `[biocontainers][${ now . toString ( ) } ] sync report` ,
@@ -137,7 +139,9 @@ async function repoFiles(kind='biocontainers', do_scan=false) {
137139 for ( const patch of patches ) {
138140 files . push ( patch . newFile ( ) . path ( ) ) ;
139141 }
140- return files ;
142+ // remove duplicates
143+ let uniqFiles = [ ...new Set ( files ) ]
144+ return uniqFiles ;
141145
142146 }
143147 console . debug ( 'take all' ) ;
@@ -590,6 +594,16 @@ async function getContainers(scan_options) {
590594
591595}
592596
597+
598+ if ( fs . existsSync ( `${ config . workdir } /sync.lock` ) ) {
599+ console . error ( 'Process is already running (sync.lock), exiting....' )
600+ process . exit ( 1 )
601+ } else {
602+ fs . writeFileSync ( `${ config . workdir } /sync.lock` , '' )
603+ }
604+
605+
606+
593607getContainers ( options ) . then ( ( containers ) => {
594608 let ts = new Date ( )
595609 console . log ( `[containers][list][date=${ ts . toLocaleString ( ) } ] ${ containers . length } to handle!` )
@@ -614,9 +628,11 @@ getContainers(options).then((containers) => {
614628 return send_report ( )
615629} ) . then ( ( ) => {
616630 console . log ( 'done' , total , docker_errors , quay_errors ) ;
631+ fs . unlinkSync ( `${ config . workdir } /sync.lock` ) ;
617632 process . exit ( 0 ) ;
618633} ) . catch ( err => {
619634 console . error ( 'oopps!' , err , docker_errors , quay_errors ) ;
635+ fs . unlinkSync ( `${ config . workdir } /sync.lock` ) ;
620636 process . exit ( 1 ) ;
621637} )
622638
0 commit comments