diff --git a/htdocs/tplfs.mjs b/htdocs/tplfs.mjs index 3a03223..761839b 100644 --- a/htdocs/tplfs.mjs +++ b/htdocs/tplfs.mjs @@ -138,8 +138,8 @@ export function TplFS(client, parent, desc) { var nodes = (await client.TIU_TEMPLATE_GETITEMS(desc.IEN)).map(x => x.IEN); nodes.push(nodeid); await client.TIU_TEMPLATE_SET_ITEMS(desc.IEN, nodes); - nodeid = (await client.TIU_TEMPLATE_GETITEMS(desc.IEN)).find(x => (x.type == 'C') && (x.name == name)); - if(nodeid) return new TplFS(client, this, nodeid); + item = (await client.TIU_TEMPLATE_GETITEMS(desc.IEN)).find(x => (x.type == 'C') && (x.name == name)); + if(item) return new TplFS(client, this, item); else throw new TplFSErrorPerm('mkdir', (this.path != '' ? this.path + '/' : '') + name, 'Failed to create directory'); } finally { await client.TIU_TEMPLATE_UNLOCK(desc.IEN); @@ -217,9 +217,9 @@ export function EncFS(fs, data_encrypt, data_decrypt, path_encrypt, path_decrypt this.list = async (filter=null) => (await fs.list(filter)).map(x => new EncFS(x, data_encrypt, data_decrypt, path_encrypt, path_decrypt)); this.open = async (path) => new EncFS(await fs.open(await path_encrypt(path)), data_encrypt, data_decrypt, path_encrypt, path_decrypt); - this.mkdir = async (path, tries=5, delay=1000) => new EncFS(await fs.mkdir(await path_encrypt(path), tries=5, delay=1000), data_encrypt, data_decrypt, path_encrypt, path_decrypt); - this.create = async (path, data, mkdir=false, tries=5, delay=1000) => new EncFS(await fs.create(await path_encrypt(path), await data_encrypt(data), mkdir=false, tries=5, delay=1000), data_encrypt, data_decrypt, path_encrypt, path_decrypt); - this.remove = async (path, tries=5, delay=1000) => await fs.remove(await path_encrypt(path), tries=5, delay=1000); + this.mkdir = async (path, tries=5, delay=1000) => new EncFS(await fs.mkdir(await path_encrypt(path), tries, delay), data_encrypt, data_decrypt, path_encrypt, path_decrypt); + this.create = async (path, data, mkdir=false, tries=5, delay=1000) => new EncFS(await fs.create(await path_encrypt(path), await data_encrypt(data), mkdir, tries, delay), data_encrypt, data_decrypt, path_encrypt, path_decrypt); + this.remove = async (path, tries=5, delay=1000) => await fs.remove(await path_encrypt(path), tries, delay); this.update = async (path, data) => new EncFS(await fs.update(await path_encrypt(path), await data_encrypt(data)), data_encrypt, data_decrypt, path_encrypt, path_decrypt); this.cat = async (path) => await data_decrypt(await fs.cat(await path_encrypt(path))); }