Files
splatoon3.ink/app/common/fs.mjs
Matt Isenhower 941a6eb258 Remove unused catch binding variables in fs.mjs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 10:09:17 -08:00

35 lines
759 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) {
try {
await fs.access(file);
return true;
} catch {
// Not on local disk; check VFS (S3 listing) as fallback
return (await vfs.has(file)) ?? false;
}
}
// Determine whether a file is older than a given cutoff date (or doesn't exist)
export async function olderThan(file, cutoff) {
try {
let stat = await fs.stat(file);
return stat.mtime < cutoff;
} catch {
// Not on local disk; check VFS (S3 listing) as fallback
const mtime = await vfs.getMtime(file);
if (mtime !== null) {
return mtime < cutoff;
}
return true;
}
}