From 0a374a3dd1008864cb4d6ea0c67a5080f2427b28 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Mon, 26 Apr 2021 18:15:16 -0400 Subject: simplified, does not ensure blobs anymore --- lib/channels-lib.js | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/lib/channels-lib.js b/lib/channels-lib.js index e70bb2b..327ec38 100644 --- a/lib/channels-lib.js +++ b/lib/channels-lib.js @@ -1,9 +1,6 @@ var pull = require("pull-stream"); var Pushable = require("pull-pushable"); var many = require("./pull-many-v2"); -const fs = require("fs"); -const home = require("os").homedir(); -const path = require("path"); // Change to 'true' to get debugging output DEBUG = false @@ -12,10 +9,6 @@ FRIENDS_POLL_TIME = 1 // ms GRAPH_TYPE = "follow" MAX_HOPS = 1 -SBOT_ROOT = path.join(home, ".ssb"); -SBOT_BLOB_DIR = path.join(SBOT_ROOT, "blobs"); -SBOT_BLOBS_FILE = path.join(SBOT_BLOB_DIR, "allowed_blobs"); - class StreamData { constructor() { this.finished = false, @@ -33,7 +26,6 @@ class StreamController { constructor(client, opts) { this.client = client, this.outputStream = Pushable(), - this.allowedBlobs = [], this.streamData = { channelStream: new StreamData(), hashtagStream: new StreamData(), @@ -73,10 +65,6 @@ class StreamController { } this.pushNewlySafeMessages(); - fs.writeFile(SBOT_BLOBS_FILE, this.allowedBlobs.join("\n"), function(err) { - debug("Failed to write allowed blobs to file: \n" + err); - }); - this.outputStream.end(); }, this.requestBlobs = function(msg) { @@ -96,8 +84,6 @@ class StreamController { } } this.getBlob = function(blobId) { - this.allowedBlobs.push(blobId); - debug("Ensuring existence of blob with ID " + blobId); client.blobs.has(blobId, function(err, has) { if(err) { @@ -116,7 +102,6 @@ class StreamController { module.exports = { getMessages: function(client, channelName, opts, preserve, cb, hops=MAX_HOPS) { - ensureFiles(); client.friends.hops({ dunbar: Number.MAX_SAFE_INTEGER, max: hops @@ -192,23 +177,6 @@ function createChannelStream(client, channelName, opts) { return query; } -function ensureFiles() { - if (!fs.existsSync(SBOT_ROOT)) { - debug("no ~/.ssb folder detected, creating it..."); - fs.mkdirSync(SBOT_ROOT); - } - - if (!fs.existsSync(SBOT_BLOB_DIR)) { - debug("no blobs folder detected, creating it..."); - fs.mkdirSync(SBOT_BLOB_DIR); - } - - if (!fs.existsSync(SBOT_BLOBS_FILE)) { - debug("no metadata file found, creating it..."); - fs.writeFileSync(SBOT_BLOBS_FILE, ""); - } -} - function debug(message) { if(DEBUG) { var timestamp = new Date(); -- cgit v1.2.3