diff --git a/server/cache.js b/server/cache.js index ede90b21..159fc2aa 100644 --- a/server/cache.js +++ b/server/cache.js @@ -39,7 +39,7 @@ middlewareRouter.use(async (req, res) => { exports.middleware = middlewareRouter -exports.add = async (id, newModified, content) => { +exports.add = async (id, newModified, content, ttl) => { if (!newModified) throw new Error(`Refusing to store ${id} without modified time.`) const data = await cache.get(id) @@ -49,7 +49,7 @@ exports.add = async (id, newModified, content) => { // if there was previous data and it is not older than the new data, don't do anything if (oldContent && modified && !isNewer(modified, newModified)) return // nothing to do if data is current // store new data in the cache - return cache.set(id, {content, modified: newModified, id}) + return cache.set(id, {content, modified: newModified, id}, {ttl: ttl}) } // expose the purgeCache method externally so that list can call while building tree diff --git a/server/list.js b/server/list.js index 44333760..a01bcb0f 100644 --- a/server/list.js +++ b/server/list.js @@ -240,7 +240,7 @@ async function setRedirects(oldDocsInfo, newDocsInfo) { // if no lastPath, file is a new addition to the drive if (currPath && lastPath && currPath !== lastPath) { log.info(`Doc ${id} moved, REDIRECT ${lastPath} → ${currPath}`) - cache.add(lastPath, new Date(), {redirect: currPath}) + cache.add(lastPath, new Date(), {redirect: currPath}, 0) } }) }