Skip to content

Commit 2d6e5ea

Browse files
committed
record container list with timestamp for reuse in case of failure
1 parent 9833a51 commit 2d6e5ea

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

bioconda-backup/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const s3 = new AWS.S3({
2626
});
2727
const registry = config.registry.host
2828

29+
const containerFileList = 'biocontainers_' + Date.now() + '.json'
30+
2931
var docker_errors = 0;
3032
var quay_errors = 0;
3133
var last_login = 0;
@@ -477,7 +479,7 @@ async function dockerhub(containers, scan_options) {
477479
console.log('[docker]', c);
478480
if(!tags || tags.length==0) {
479481
tags = await getDockerhubTags(c, scan_options);
480-
await fs.writeFileSync(`${config.workdir}/biocontainers.json`, JSON.stringify({name: c, tags: tags, type: 'docker'}) + "\n", {flag: 'a+'});
482+
await fs.writeFileSync(`${config.workdir}/${containerFileList}`, JSON.stringify({name: c, tags: tags, type: 'docker'}) + "\n", {flag: 'a+'});
481483
}
482484
} catch(err) {
483485
docker_errors++;
@@ -508,7 +510,7 @@ async function quayio(containers, scan_options) {
508510
try {
509511
if(!tags || tags.length==0) {
510512
tags = await getQuayioTags(c, scan_options);
511-
await fs.writeFileSync(`${config.workdir}/biocontainers.json`, JSON.stringify({name: c, tags: tags, type: 'bioconda'})+"\n", {flag: 'a+'});
513+
await fs.writeFileSync(`${config.workdir}/${containerFileList}`, JSON.stringify({name: c, tags: tags, type: 'bioconda'})+"\n", {flag: 'a+'});
512514
}
513515
} catch(err) {
514516
quay_errors++;
@@ -610,11 +612,6 @@ if(fs.existsSync(`${config.workdir}/sync.lock`)) {
610612
fs.writeFileSync(`${config.workdir}/sync.lock`, '')
611613
}
612614

613-
if(fs.existsSync(`${config.workdir}/biocontainers.json`)) {
614-
fs.unlinkSync(`${config.workdir}/biocontainers.json`);
615-
}
616-
617-
618615

619616
getContainers(options).then((containers) => {
620617
let ts = new Date()
@@ -641,6 +638,7 @@ getContainers(options).then((containers) => {
641638
}).then(() => {
642639
console.log('done', total, docker_errors, quay_errors);
643640
fs.unlinkSync(`${config.workdir}/sync.lock`);
641+
fs.unlinkSync(`${config.workdir}/${containerFileList}`)
644642
process.exit(0);
645643
}).catch(err => {
646644
console.error('oopps!', err, docker_errors, quay_errors);

0 commit comments

Comments
 (0)