splatoon3.ink/app/common/fs.mjs
Matt Isenhower 41c9f9a315 Add VFS layer to avoid downloading files only needed for existence checks
Uses S3 ListObjectsV2 to build an in-memory file listing at startup,
allowing exists() and olderThan() to resolve from the listing instead
of requiring files on disk. sync:download now skips assets/splatnet/,
data/xrank/, data/festivals.ranking.*, and status-screenshots/.

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

38 lines
696 B
JavaScript

import fs from 'fs/promises';
import vfs from './vfs.mjs';
export function mkdirp(dir) {
return fs.mkdir(dir, { recursive: true });
}
export async function exists(file) {
const vfsResult = vfs.has(file);
if (vfsResult !== null) {
return vfsResult;
}
try {
await fs.access(file);
return true;
} catch (e) {
return false;
}
}
// Determine whether a file is older than a given cutoff date (or doesn't exist)
export async function olderThan(file, cutoff) {
const mtime = vfs.getMtime(file);
if (mtime !== null) {
return mtime < cutoff;
}
try {
let stat = await fs.stat(file);
return stat.mtime < cutoff;
} catch (e) {
return true;
}
}