replace pinned.js with low-profile streaming implementation

This commit is contained in:
ansuz 2020-02-13 17:46:10 -05:00
parent 609eddc9e1
commit 3dc789cbca
4 changed files with 38 additions and 6 deletions

View File

@ -9,7 +9,6 @@ const Nacl = require("tweetnacl/nacl-fast");
const Util = require("../common-util");
const nThen = require("nthen");
const Saferphore = require("saferphore");
const Pinned = require('../../scripts/pinned');
//const escapeKeyCharacters = Util.escapeKeyCharacters;
const unescapeKeyCharacters = Util.unescapeKeyCharacters;
@ -432,7 +431,7 @@ Pinning.getDeletedPads = function (Env, channels, cb) {
// inform that the
Pinning.loadChannelPins = function (Env) {
Pinned.load(function (err, data) {
Pins.list(function (err, data) {
if (err) {
Env.Log.error("LOAD_CHANNEL_PINS", err);

View File

@ -1,7 +1,6 @@
/* jshint esversion: 6, node: true */
const Fs = require('fs');
const nThen = require('nthen');
const Pinned = require('./pinned');
const Nacl = require('tweetnacl/nacl-fast');
const Path = require('path');
const Pins = require('../lib/pins');
@ -41,7 +40,7 @@ nThen((waitFor) => {
pinned = Pins.calculateFromLog(content.toString('utf8'), f);
}));
}).nThen((waitFor) => {
Pinned.load(waitFor((err, d) => {
Pins.list(waitFor((err, d) => {
data = Object.keys(d);
}), {
exclude: [edPublic + '.ndjson']

View File

@ -2,7 +2,7 @@ var nThen = require("nthen");
var Store = require("../storage/file");
var BlobStore = require("../storage/blob");
var Pinned = require("./pinned");
var Pins = require("../lib/pins");
var config = require("../lib/load-config");
// the administrator should have set an 'inactiveTime' in their config
@ -38,7 +38,7 @@ nThen(function (w) {
store = _;
})); // load the list of pinned files so you know which files
// should not be archived or deleted
Pinned.load(w(function (err, _) {
Pins.list(w(function (err, _) {
if (err) {
w.abort();
return void console.error(err);

View File

@ -0,0 +1,34 @@
/*jshint esversion: 6 */
const Pins = require("../../lib/pins");
var stats = {
users: 0,
lines: 0,
pinned: 0,
events: 0,
};
Pins.list(function (err, pinned) {
for (var id in pinned) {
console.log(id);
stats.pinned++;
}
console.log(stats);
}, {
pinPath: require("../../lib/load-config").pinPath
});
/*
function (ref, safeKey, pinned) {
stats.users++;
stats.lines += ref.index;
Object.keys(ref.pins).forEach(function (id) {
if (!pinned[id]) {
pinned[id] = true;
stats.pinned++;
}
});
//console.log("pin", stats.events++);
//console.log(ref, safeKey);
}*/