From daed626dc04d86cce8ef4a690798192d3b4b46dd Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Sat, 16 Nov 2024 13:27:14 -0800 Subject: [PATCH] Split out upload/download sync actions --- package.json | 4 +++- src/app/index.js | 2 ++ src/app/sync/S3Syncer.js | 5 ----- src/app/sync/index.js | 29 ++++++++++++++++++++++++----- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 035b554..1153e9e 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,14 @@ "build": "vue-cli-service build --modern --no-clean", "lint": "vue-cli-service lint", "cron": "node src/app/cron", - "start": "npm run sync && npm run splatnet && npm run twitter && npm run cron", + "start": "npm run sync:download && npm run splatnet && npm run twitter && npm run cron", "locale-man": "node node_modules/locale-man/ -l en,es,es-MX,fr,fr-CA,de,nl,it,ru,ja -o src/locale", "splatnet": "node src/app splatnet", "twitter": "node src/app twitter", "twitter:test": "node src/app twitterTest", "sync": "node src/app sync", + "sync:upload": "node src/app syncUpload", + "sync:download": "node src/app syncDownload", "utility:copyTranslation": "node src/utility copyTranslation", "utility:getSplatNetLanguageFiles": "node src/utility getSplatNetLanguageFiles", "utility:updateGear": "node src/utility updateGear" diff --git a/src/app/index.js b/src/app/index.js index f96e672..6ac9f9c 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -5,6 +5,8 @@ module.exports = { twitter: require('./twitter').maybePostTweets, twitterTest: require('./twitter').testScreenshots, sync: require('./sync').sync, + syncUpload: require('./sync').syncUpload, + syncDownload: require('./sync').syncDownload, }; require('make-runnable/custom')({ printOutputFrame: false }); diff --git a/src/app/sync/S3Syncer.js b/src/app/sync/S3Syncer.js index 3dec2b8..5a939b0 100644 --- a/src/app/sync/S3Syncer.js +++ b/src/app/sync/S3Syncer.js @@ -5,11 +5,6 @@ const mime = require('mime-types'); class S3Syncer { - async sync() { - await this.download(); - await this.upload(); - } - download() { this.log('Downloading files...'); diff --git a/src/app/sync/index.js b/src/app/sync/index.js index 609f6e4..5bb78b3 100644 --- a/src/app/sync/index.js +++ b/src/app/sync/index.js @@ -9,16 +9,35 @@ function canSync() { ); } -function sync() { +async function doSync(download, upload) { if (!canSync()) { console.warn('Missing S3 connection parameters'); return; } - console.info('Syncing files...'); - const syncer = new S3Syncer(); - return syncer.sync(); + + if (download) { + console.info('Downloading files...'); + await syncer.download(); + } + + if (upload) { + console.info('Uploading files...'); + await syncer.upload(); + } } -module.exports = { canSync, sync }; +function sync() { + return doSync(true, true); +} + +function syncUpload() { + return doSync(false, true); +} + +function syncDownload() { + return doSync(true, false); +} + +module.exports = { canSync, sync, syncUpload, syncDownload };