diff --git a/app/common/fs.mjs b/app/common/fs.mjs index 8f93c15..5bed895 100644 --- a/app/common/fs.mjs +++ b/app/common/fs.mjs @@ -6,32 +6,29 @@ export function mkdirp(dir) { } 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; + // Not on local disk; check VFS (S3 listing) as fallback + return 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) { - const mtime = vfs.getMtime(file); - if (mtime !== null) { - return mtime < cutoff; - } - try { let stat = await fs.stat(file); return stat.mtime < cutoff; } catch (e) { + // Not on local disk; check VFS (S3 listing) as fallback + const mtime = vfs.getMtime(file); + if (mtime !== null) { + return mtime < cutoff; + } + return true; } } diff --git a/app/common/vfs.mjs b/app/common/vfs.mjs index 1b64f59..22ae017 100644 --- a/app/common/vfs.mjs +++ b/app/common/vfs.mjs @@ -103,23 +103,6 @@ class VirtualFileSystem { return entry ? entry.lastModified : null; } - /** - * Track a file that was just written locally. - * Ensures subsequent has() calls return true without hitting disk. - * @param {string} localPath - */ - track(localPath) { - if (!this._loaded) return; - - const key = this._localPathToKey(localPath); - if (key === null) return; - - this._listing.set(key, { - lastModified: new Date(), - size: 0, - }); - } - /** * Convert a local path (e.g. 'dist/assets/splatnet/foo.png') * to an S3 key (e.g. 'assets/splatnet/foo.png'). diff --git a/app/data/ImageProcessor.mjs b/app/data/ImageProcessor.mjs index 343949c..254b36f 100644 --- a/app/data/ImageProcessor.mjs +++ b/app/data/ImageProcessor.mjs @@ -4,7 +4,6 @@ import PQueue from 'p-queue'; import prefixedConsole from '../common/prefixedConsole.mjs'; import { normalizeSplatnetResourcePath } from '../common/util.mjs'; import { exists, mkdirp } from '../common/fs.mjs'; -import vfs from '../common/vfs.mjs'; const queue = new PQueue({ concurrency: 4 }); @@ -72,7 +71,6 @@ export default class ImageProcessor await mkdirp(path.dirname(this.localPath(destination))); await fs.writeFile(this.localPath(destination), result.body); - vfs.track(this.localPath(destination)); } catch (e) { this.console.error(`Image download failed for ${destination}`, e); }