aboutsummaryrefslogtreecommitdiffstats
path: root/extension
diff options
context:
space:
mode:
authorOmar Rizwan <omar.rizwan@gmail.com>2019-02-28 01:05:28 -0800
committerOmar Rizwan <omar.rizwan@gmail.com>2019-02-28 01:05:28 -0800
commita3f25d346f5b17bfbfbac13265812f3360e9fe45 (patch)
tree28c5c30e07ea853f5c008b74683bbf4516439683 /extension
parentb18fc10e1420cdb32068b4452e9c1e5d9fa7024d (diff)
Add tabs/by-title. Fix symlink stuff to make it work?
FUSE readlink needing to return 0 + getattr needing to return correct st_size was _not_ obvious, lol.
Diffstat (limited to 'extension')
-rw-r--r--extension/background.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/extension/background.js b/extension/background.js
index 0bf5808..0d3186b 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -74,6 +74,28 @@ const router = {
* }
* },
*/
+ "by-title": {
+ async readdir() {
+ const tabs = await queryTabs();
+ return tabs.map(tab => sanitize(String(tab.title)) + "_" + String(tab.id));
+ },
+ "*": {
+ async getattr(path) {
+ const st_size = (await this.readlink(path)).length + 1;
+ return {
+ st_mode: unix.S_IFLNK | 0444,
+ st_nlink: 1,
+ // You _must_ return correct linkee path length from getattr!
+ st_size
+ };
+ },
+ async readlink(path) {
+ const parts = path.split("_");
+ const id = parts[parts.length - 1];
+ return "../by-id/" + id;
+ }
+ }
+ },
"by-id": {
async readdir() {
const tabs = await queryTabs();
@@ -190,6 +212,10 @@ async function read(path, fh, size, offset) {
let route = findRoute(path);
if (route.read) return route.read(path, fh, size, offset);
}
+async function readlink(path) {
+ let route = findRoute(path);
+ if (route.readlink) return route.readlink(path);
+}
async function release(path, fh) {
let route = findRoute(path);
@@ -248,6 +274,13 @@ async function onmessage(event) {
op: 'release'
};
+ } else if (req.op === 'readlink') {
+ const buf = await readlink(req.path)
+ response = {
+ op: 'readlink',
+ buf
+ };
+
} else if (req.op === 'opendir') {
response = {
op: 'opendir',