From 0701f308dbdc4ca220c3af5685eec5c80369a3b6 Mon Sep 17 00:00:00 2001 From: mahsashadi <70196035+mahsashadi@users.noreply.github.com> Date: Sun, 29 Aug 2021 09:19:56 +0430 Subject: [PATCH 1/3] Fix unused options in readdir system VFS adapter --- src/adapters/vfs/system.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adapters/vfs/system.js b/src/adapters/vfs/system.js index ceee251..16dcfd9 100644 --- a/src/adapters/vfs/system.js +++ b/src/adapters/vfs/system.js @@ -59,7 +59,7 @@ const methods = (core, request) => { return { readdir: ({path}, options) => request('readdir', { path, - options: {} + options, }, 'json').then(({body}) => body), readfile: ({path}, type, options) => From 14615e5535ec9544f328a8cf42b50d64136a784c Mon Sep 17 00:00:00 2001 From: mahsa shadi Date: Wed, 8 Sep 2021 14:22:44 +0430 Subject: [PATCH 2/3] Ignore vfs client options from being send to the server --- src/adapters/vfs/system.js | 4 ++-- src/vfs.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/adapters/vfs/system.js b/src/adapters/vfs/system.js index 16dcfd9..3c653f4 100644 --- a/src/adapters/vfs/system.js +++ b/src/adapters/vfs/system.js @@ -89,7 +89,7 @@ const methods = (core, request) => { stat: passthrough('stat'), url: ({path}, options) => Promise.resolve( - core.url(`/vfs/readfile?path=${encodeURIComponent(path)}`) + core.url(`/vfs/readfile?path.s=${encodeURIComponent(path)}`) ), search: ({path}, pattern, options) => @@ -102,7 +102,7 @@ const methods = (core, request) => { download: ({path}, options = {}) => { const json = encodeURIComponent(JSON.stringify({download: true})); - return Promise.resolve(`/vfs/readfile?options=${json}&path=` + encodeURIComponent(path)) + return Promise.resolve(`/vfs/readfile?options=${json}&path.s=` + encodeURIComponent(path)) .then(url => { return (options.target || window).open(url); }); diff --git a/src/vfs.js b/src/vfs.js index 505ff14..420bbe3 100644 --- a/src/vfs.js +++ b/src/vfs.js @@ -74,6 +74,12 @@ const handleDirectoryList = (path, options) => result => filter: options.filter })); +// Returns a new "options" object without properties from "ignore" +const filterOptions = (ignore, options) => { + ignore.forEach(item => delete options[item]); + return options; +}; + /** * Read a directory * @@ -82,7 +88,7 @@ const handleDirectoryList = (path, options) => result => * @return {Promise} A list of files */ export const readdir = (adapter, mount) => (path, options = {}) => - adapter.readdir(pathToObject(path), options, mount) + adapter.readdir(pathToObject(path), filterOptions(['showHiddenFiles', 'filter'], options), mount) .then(handleDirectoryList(path, options)); /** From a5e92a19fb3114a3304fd93e12f40ef12cf584a4 Mon Sep 17 00:00:00 2001 From: mahsa shadi Date: Sat, 11 Sep 2021 16:49:38 +0430 Subject: [PATCH 3/3] Preserving the options passed into filterOptions method --- __tests__/vfs.js | 2 +- src/vfs.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/__tests__/vfs.js b/__tests__/vfs.js index ca0a76b..4310615 100644 --- a/__tests__/vfs.js +++ b/__tests__/vfs.js @@ -79,7 +79,7 @@ describe('VFS', () => { .toBeInstanceOf(ArrayBuffer); }); - test('writefile - blob', () => { + test('#writefile - blob', () => { return expect(call('writefile', 'null:/filename', new Blob())) .resolves .toBe(-1); diff --git a/src/vfs.js b/src/vfs.js index 420bbe3..5dc80e2 100644 --- a/src/vfs.js +++ b/src/vfs.js @@ -75,10 +75,11 @@ const handleDirectoryList = (path, options) => result => })); // Returns a new "options" object without properties from "ignore" -const filterOptions = (ignore, options) => { - ignore.forEach(item => delete options[item]); - return options; -}; +const filterOptions = (ignore, options) => Object.fromEntries( + Object + .entries(options) + .filter(([k]) => !ignore.includes(k)) +); /** * Read a directory