mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-04-25 15:36:31 -05:00
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>
38 lines
696 B
JavaScript
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;
|
|
}
|
|
}
|