test('use cached process results', async () => { await fs.copy( path.join(context, 'assets', '1000x600.png'), path.join(imageCacheDir, '1000x600.97c148e.test.png') ) const files = await process(['1000x600.png'], { width: 1000 }, { withCache: true }) const cacheStats = await fs.stat(files[0].cachePath) const destStats = await fs.stat(files[0].destPath) const mDiff = cacheStats.mtimeMs - destStats.mtimeMs const bDiff = cacheStats.birthtime - destStats.birthtime expect(mDiff).toBeLessThan(32) expect(bDiff).toBeLessThan(32) expect(destStats.size).toEqual(cacheStats.size) })
fs.promises.stat(path.join(notesLocation, entry)).then(stat => { let nowDate = new Date().getTime(); let text = new Date().toLocaleDateString("en-US", { month: 'long', day: 'numeric' }); if (nowDate - 1000 * 60 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 1000) + " seconds ago"; else if (nowDate - 1000 * 60 * 60 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 60 / 1000) + " minutes ago"; else if (nowDate - 1000 * 60 * 60 * 24 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 60 / 60 / 1000) + " hours ago"; else if (nowDate - 1000 * 60 * 60 * 24 * 31 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 60 / 60 / 24 / 1000) + " days ago"; card.actions.lastModified.innerText = text });
/** * Check if a page is newer than its cached version. * @param {string} uri * @param {number} lastEditedTime * @param {string} cacheDir */ function isPageUpdated(pageId, lastEditedTime, cacheDir) { const cacheFileName = pageId + '.json' const cacheFilePath = path.join(cacheDir, cacheFileName) if (fs.existsSync(cacheFilePath)) { const lastCacheTime = fs.statSync(cacheFilePath).mtimeMs return lastEditedTime > lastCacheTime } else { return true } }
wrap((fd: number, bufPtr: number) => { const stats = CHECK_FD(fd, WASI_RIGHT_FD_FILESTAT_GET); const rstats = fs.fstatSync(stats.real); this.refreshMemory(); this.view.setBigUint64(bufPtr, BigInt(rstats.dev), true); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.ino), true); bufPtr += 8; this.view.setUint8(bufPtr, stats.filetype); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.nlink), true); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.size), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.atimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.mtimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.ctimeMs), true); return WASI_ESUCCESS; })
fs.readdir('Files', (err, files) => { if(err){ res.status(500).send(err); } else { let s = []; for(var i = 0; i<files.length; i++){ s.push({ name: files[i], date: fs.statSync("Files/" + files[i]).mtimeMs }); } res.send(db.builder.buildObject({ files: { file: s } })); } });
const isDirExists = fs.existsSync(beatmapPath) && dirStats.isDirectory(); if (isDirExists) { const date = dirStats.mtimeMs; const assets = fs.readdirSync(beatmapPath); for (let j = 0; j < assets.length; j++) {
wrap((fd, flags, pathPtr, pathLen, bufPtr) => { const stats = CHECK_FD(fd, WASI_RIGHT_PATH_FILESTAT_GET); if (!stats.path) { return WASI_EINVAL; } this.refreshMemory(); const p = Buffer.from(this.memory.buffer, pathPtr, pathLen).toString(); const rstats = fs.statSync(path.resolve(stats.path, p)); this.view.setBigUint64(bufPtr, BigInt(rstats.dev), true); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.ino), true); bufPtr += 8; this.view.setUint8(bufPtr, translateFileAttributes(undefined, rstats).filetype); bufPtr += 4; this.view.setUint32(bufPtr, Number(rstats.nlink), true); bufPtr += 4; this.view.setBigUint64(bufPtr, BigInt(rstats.size), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.atimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.mtimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.ctimeMs), true); bufPtr += 8; return WASI_ESUCCESS; })
meta.filename = path.basename(filename); meta.added = stats.atimeMs; meta.modified = stats.mtimeMs; meta.size = stats.size; if (!isPlugin) {
wrap((fd, bufPtr) => { const stats = CHECK_FD(fd, WASI_RIGHT_FD_FILESTAT_GET); const rstats = fs.fstatSync(stats.real); this.refreshMemory(); this.view.setBigUint64(bufPtr, BigInt(rstats.dev), true); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.ino), true); bufPtr += 8; this.view.setUint8(bufPtr, stats.filetype); bufPtr += 4; this.view.setUint32(bufPtr, Number(rstats.nlink), true); bufPtr += 4; this.view.setBigUint64(bufPtr, BigInt(rstats.size), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.atimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.mtimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.ctimeMs), true); bufPtr += 8; return WASI_ESUCCESS; })
this.view.setBigUint64(bufPtr, msToNs(rstats.atimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.mtimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.ctimeMs), true);
test('use cached process results', async () => { await fs.copy( path.join(context, 'assets', '1000x600.png'), path.join(imageCacheDir, '1000x600.97c148e.test.png') ) const files = await process(['1000x600.png'], { width: 1000 }, { withCache: true }) const cacheStats = await fs.stat(files[0].cachePath) const destStats = await fs.stat(files[0].destPath) const mDiff = cacheStats.mtimeMs - destStats.mtimeMs const bDiff = cacheStats.birthtime - destStats.birthtime expect(mDiff).toBeLessThan(32) expect(bDiff).toBeLessThan(32) expect(destStats.size).toEqual(cacheStats.size) })
fs.promises.stat(path.join(notesLocation, entry)).then(stat => { let nowDate = new Date().getTime(); let text = new Date().toLocaleDateString("en-US", { month: 'long', day: 'numeric' }); if (nowDate - 1000 * 60 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 1000) + " seconds ago"; else if (nowDate - 1000 * 60 * 60 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 60 / 1000) + " minutes ago"; else if (nowDate - 1000 * 60 * 60 * 24 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 60 / 60 / 1000) + " hours ago"; else if (nowDate - 1000 * 60 * 60 * 24 * 31 < stat.mtimeMs) text = Math.trunc((nowDate - stat.mtimeMs) / 60 / 60 / 24 / 1000) + " days ago"; card.actions.lastModified.innerText = text });
wrap((fd: number, bufPtr: number) => { const stats = CHECK_FD(fd, WASI_RIGHT_FD_FILESTAT_GET); const rstats = fs.fstatSync(stats.real); this.refreshMemory(); this.view.setBigUint64(bufPtr, BigInt(rstats.dev), true); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.ino), true); bufPtr += 8; this.view.setUint8(bufPtr, stats.filetype); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.nlink), true); bufPtr += 8; this.view.setBigUint64(bufPtr, BigInt(rstats.size), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.atimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.mtimeMs), true); bufPtr += 8; this.view.setBigUint64(bufPtr, msToNs(rstats.ctimeMs), true); return WASI_ESUCCESS; })
meta.filename = path.basename(filename); meta.added = stats.atimeMs; meta.modified = stats.mtimeMs; meta.size = stats.size; if (!isPlugin) {