From 0df1919259ff12b0c24c0309531b114375fe4d47 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 26 Oct 2022 00:38:52 +0300 Subject: [PATCH] minor fix + simplified .exists(..)... Signed-off-by: Alex A. Naanou --- pwiki/store/base.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pwiki/store/base.js b/pwiki/store/base.js index ab53e4e..2d66000 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -206,10 +206,21 @@ module.BaseStore = { // -> // -> false // - // XXX might be a good idea to cache this... + // XXX INDEXED... + exists: async function(path){ + var {path, args} = + pwpath.splitArgs( + pwpath.sanitize(path, 'string')) + //return new Set(await this.paths).has(path) ? + //return (await this.paths).indexOf(path) != -1 ? + return (await this.paths).includes(path) ? + pwpath.joinArgs(path, args) + : undefined }, + /*/ __exists__: async function(path){ return path in this.data && path }, + // XXX might be a good idea to cache this... exists: async function(path){ var {path, args} = pwpath.splitArgs( @@ -235,6 +246,7 @@ module.BaseStore = { if(typeof(res) != 'string'){ return false } return pwpath.joinArgs(res, args) }, + //*/ // find the closest existing alternative path... find: async function(path, strict=false){ var {path, args} = pwpath.splitArgs(path) @@ -500,8 +512,7 @@ module.BaseStore = { path = await this.exists(path) if(typeof(path) == 'string'){ await this.__delete__(path) - this.index('remove', path) - this.onDelete(path) } + this.index('remove', path) } return this }, delete: types.event.Event('delete', function(handler, path){