Files
splatoon3.ink/app/sync/index.mjs
Matt Isenhower 6dac044a69 Make VFS load lazily
VFS now loads on first has()/getMtime() call rather than requiring
explicit initialization in sync/index.mjs. This ensures it works
regardless of entry point (sync:download, splatnet:quick, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:55:13 -08:00

42 lines
775 B
JavaScript

import S3Syncer from './S3Syncer.mjs';
export function canSync() {
return !!(
process.env.AWS_ACCESS_KEY_ID &&
process.env.AWS_SECRET_ACCESS_KEY &&
process.env.AWS_S3_BUCKET &&
process.env.AWS_S3_PRIVATE_BUCKET
);
}
async function doSync(download, upload) {
if (!canSync()) {
console.warn('Missing S3 connection parameters');
return;
}
const syncer = new S3Syncer();
if (download) {
console.info('Downloading files...');
await syncer.download();
}
if (upload) {
console.info('Uploading files...');
await syncer.upload();
}
}
export function sync() {
return doSync(true, true);
}
export function syncUpload() {
return doSync(false, true);
}
export function syncDownload() {
return doSync(true, false);
}