From adf4330f5437dcc655936120a3538967c781391e Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Tue, 1 Dec 2020 21:46:21 -0800 Subject: start refactor to use frozen instead of cJSON; I can list dirs, but can't read file yet also (... at the same time ...) more work on refactoring background.js to eliminate middle layer, I guess --- extension/background.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'extension') diff --git a/extension/background.js b/extension/background.js index 3fe2341..643b43b 100644 --- a/extension/background.js +++ b/extension/background.js @@ -155,7 +155,7 @@ router["/tabs/by-id/*/resources"] = { } }; router["/tabs/by-id/*/resources/*"] = { - async getattr(path) { + async getattr({path}) { const tabId = parseInt(pathComponent(path, -3)); const suffix = pathComponent(path, -1); @@ -182,10 +182,10 @@ router["/tabs/by-id/*/resources/*"] = { } } }, - async open(path) { - + async open({path}) { + // FIXME: cache the file }, - async read(path, fh, size, offset) { + async read({path, fh, size, offset}) { const tabId = parseInt(pathComponent(path, -3)); const suffix = pathComponent(path, -1); @@ -210,7 +210,7 @@ router["/tabs/by-id/*/resources/*"] = { } throw new UnixError(unix.ENOENT); }, - async release(path, fh) { + async release({path, fh}) { return {}; } }; @@ -412,12 +412,12 @@ function findRoute(path) { let port; async function onMessage(req) { - /* console.log('req', req);*/ + console.log('req', req); let response = { op: req.op, error: unix.EIO }; /* console.time(req.op + ':' + req.path);*/ try { - console.log(req.path, req.op, findRoute(req.path)[req.op]); + console.log(findRoute(req.path)[req.op]); response = await findRoute(req.path)[req.op](req); response.op = req.op; @@ -430,7 +430,7 @@ async function onMessage(req) { } /* console.timeEnd(req.op + ':' + req.path);*/ - /* console.log('resp', response);*/ + console.log('resp', response); port.postMessage(response); }; -- cgit v1.2.3