diff --git a/src/puter-js/src/modules/FileSystem/index.js b/src/puter-js/src/modules/FileSystem/index.js index 97ed44644..532d5be2b 100644 --- a/src/puter-js/src/modules/FileSystem/index.js +++ b/src/puter-js/src/modules/FileSystem/index.js @@ -116,7 +116,7 @@ export class PuterJSFileSystemModule extends AdvancedBase { this.socket.on('cache.updated', (msg) => { // check original_client_socket_id and if it matches this.socket.id, don't post update if (msg.original_client_socket_id !== this.socket.id) { - this.postUpdate(); + this.invalidateCache(); } }); @@ -124,7 +124,7 @@ export class PuterJSFileSystemModule extends AdvancedBase { this.socket.on('item.renamed', (item) => { // check original_client_socket_id and if it matches this.socket.id, don't post update if (item.original_client_socket_id !== this.socket.id) { - this.postUpdate(); + this.invalidateCache(); } }); @@ -218,10 +218,10 @@ export class PuterJSFileSystemModule extends AdvancedBase { * @memberof PuterJSFileSystemModule * @returns {void} */ - postUpdate() { + invalidateCache() { // Action: Flush local cache puter._cache.flushall(); - console.log('postUpdate triggered, cache flushed'); + console.log('invalidateCache triggered, cache flushed'); // Action: Update last valid time // diff --git a/src/puter-js/src/modules/FileSystem/operations/copy.js b/src/puter-js/src/modules/FileSystem/operations/copy.js index 59fc1ae4a..0ba06c2fd 100644 --- a/src/puter-js/src/modules/FileSystem/operations/copy.js +++ b/src/puter-js/src/modules/FileSystem/operations/copy.js @@ -56,7 +56,7 @@ const copy = function (...args) { dedupe_name: (options.dedupe_name || options.dedupeName), })); - this.postUpdate(); + this.invalidateCache(); }) } diff --git a/src/puter-js/src/modules/FileSystem/operations/mkdir.js b/src/puter-js/src/modules/FileSystem/operations/mkdir.js index 3858a29fe..8e7a411f8 100644 --- a/src/puter-js/src/modules/FileSystem/operations/mkdir.js +++ b/src/puter-js/src/modules/FileSystem/operations/mkdir.js @@ -54,7 +54,7 @@ const mkdir = function (...args) { create_missing_parents: (options.recursive || options.createMissingParents) ?? false, })); - this.postUpdate(); + this.invalidateCache(); }) } diff --git a/src/puter-js/src/modules/FileSystem/operations/move.js b/src/puter-js/src/modules/FileSystem/operations/move.js index 8bdadb8ae..a691febf2 100644 --- a/src/puter-js/src/modules/FileSystem/operations/move.js +++ b/src/puter-js/src/modules/FileSystem/operations/move.js @@ -66,7 +66,7 @@ const move = function (...args) { original_client_socket_id: options.excludeSocketID, })); - this.postUpdate(); + this.invalidateCache(); }) } diff --git a/src/puter-js/src/modules/FileSystem/operations/readdir.js b/src/puter-js/src/modules/FileSystem/operations/readdir.js index ffabb555e..54b3051e7 100644 --- a/src/puter-js/src/modules/FileSystem/operations/readdir.js +++ b/src/puter-js/src/modules/FileSystem/operations/readdir.js @@ -65,17 +65,16 @@ const readdir = async function (...args) { // Cache the result if it's not bigger than MAX_CACHE_SIZE const MAX_CACHE_SIZE = 20 * 1024 * 1024; - const EXPIRE_TIME = 60 * 60; // 1 hour if(resultSize <= MAX_CACHE_SIZE){ // UPSERT the cache - await puter._cache.set(cacheKey, result, { EX: EXPIRE_TIME }); + await puter._cache.set(cacheKey, result); } // set each individual item's cache for(const item of result){ - await puter._cache.set('item:' + item.id, item, { EX: EXPIRE_TIME }); - await puter._cache.set('item:' + item.path, item, { EX: EXPIRE_TIME }); + await puter._cache.set('item:' + item.id, item); + await puter._cache.set('item:' + item.path, item); } resolve(result); diff --git a/src/puter-js/src/modules/FileSystem/operations/rename.js b/src/puter-js/src/modules/FileSystem/operations/rename.js index c5156c6c2..ff377ecfc 100644 --- a/src/puter-js/src/modules/FileSystem/operations/rename.js +++ b/src/puter-js/src/modules/FileSystem/operations/rename.js @@ -51,7 +51,7 @@ const rename = function (...args) { xhr.send(JSON.stringify(dataToSend)); - this.postUpdate(); + this.invalidateCache(); }) } diff --git a/src/puter-js/src/modules/FileSystem/operations/stat.js b/src/puter-js/src/modules/FileSystem/operations/stat.js index 42689d435..0102ec147 100644 --- a/src/puter-js/src/modules/FileSystem/operations/stat.js +++ b/src/puter-js/src/modules/FileSystem/operations/stat.js @@ -62,12 +62,11 @@ const stat = async function (...args) { // Cache the result if it's not bigger than MAX_CACHE_SIZE const MAX_CACHE_SIZE = 20 * 1024 * 1024; - const EXPIRE_TIME = 60 * 60; // 1 hour if(resultSize <= MAX_CACHE_SIZE){ // UPSERT the cache - await puter._cache.set('item:' + result.path, result, { EX: EXPIRE_TIME }); - await puter._cache.set('item:' + result.uid, result, { EX: EXPIRE_TIME }); + await puter._cache.set('item:' + result.path, result); + await puter._cache.set('item:' + result.uid, result); } resolve(result); diff --git a/src/puter-js/src/modules/FileSystem/operations/upload.js b/src/puter-js/src/modules/FileSystem/operations/upload.js index b23a74a96..a8979676e 100644 --- a/src/puter-js/src/modules/FileSystem/operations/upload.js +++ b/src/puter-js/src/modules/FileSystem/operations/upload.js @@ -432,7 +432,7 @@ const upload = async function(items, dirPath, options = {}){ // send request xhr.send(fd); - this.postUpdate(); + this.invalidateCache(); }) } diff --git a/src/puter-js/src/modules/FileSystem/operations/write.js b/src/puter-js/src/modules/FileSystem/operations/write.js index b882ea571..74f81e2f9 100644 --- a/src/puter-js/src/modules/FileSystem/operations/write.js +++ b/src/puter-js/src/modules/FileSystem/operations/write.js @@ -55,7 +55,7 @@ const write = async function (targetPath, data, options = {}) { throw new Error({ code: 'field_invalid', message: 'write() data parameter is an invalid type' }); } - this.postUpdate(); + this.invalidateCache(); // perform upload return this.upload(data, parent, options);