|
|
@ -8,7 +8,7 @@ const nThen = require("nthen");
|
|
|
|
//const escapeKeyCharacters = Util.escapeKeyCharacters;
|
|
|
|
//const escapeKeyCharacters = Util.escapeKeyCharacters;
|
|
|
|
const unescapeKeyCharacters = Util.unescapeKeyCharacters;
|
|
|
|
const unescapeKeyCharacters = Util.unescapeKeyCharacters;
|
|
|
|
|
|
|
|
|
|
|
|
var sumChannelSizes = function (sizes) {
|
|
|
|
var sumChannelSizes = function (sizes) { // FIXME this synchronous code could be done by a worker
|
|
|
|
return Object.keys(sizes).map(function (id) { return sizes[id]; })
|
|
|
|
return Object.keys(sizes).map(function (id) { return sizes[id]; })
|
|
|
|
.filter(function (x) {
|
|
|
|
.filter(function (x) {
|
|
|
|
// only allow positive numbers
|
|
|
|
// only allow positive numbers
|
|
|
@ -171,7 +171,7 @@ Pinning.pinChannel = function (Env, safeKey, channels, cb) {
|
|
|
|
|
|
|
|
|
|
|
|
getMultipleFileSize(Env, toStore, function (e, sizes) {
|
|
|
|
getMultipleFileSize(Env, toStore, function (e, sizes) {
|
|
|
|
if (typeof(sizes) === 'undefined') { return void cb(e); }
|
|
|
|
if (typeof(sizes) === 'undefined') { return void cb(e); }
|
|
|
|
var pinSize = sumChannelSizes(sizes);
|
|
|
|
var pinSize = sumChannelSizes(sizes); // FIXME don't do this in the main thread...
|
|
|
|
|
|
|
|
|
|
|
|
getFreeSpace(Env, safeKey, function (e, free) {
|
|
|
|
getFreeSpace(Env, safeKey, function (e, free) {
|
|
|
|
if (typeof(free) === 'undefined') {
|
|
|
|
if (typeof(free) === 'undefined') {
|
|
|
@ -186,7 +186,7 @@ Pinning.pinChannel = function (Env, safeKey, channels, cb) {
|
|
|
|
toStore.forEach(function (channel) {
|
|
|
|
toStore.forEach(function (channel) {
|
|
|
|
session.channels[channel] = true;
|
|
|
|
session.channels[channel] = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
getHash(Env, safeKey, cb);
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -217,7 +217,7 @@ Pinning.unpinChannel = function (Env, safeKey, channels, cb) {
|
|
|
|
toStore.forEach(function (channel) {
|
|
|
|
toStore.forEach(function (channel) {
|
|
|
|
delete session.channels[channel];
|
|
|
|
delete session.channels[channel];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
getHash(Env, safeKey, cb);
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -270,9 +270,7 @@ Pinning.resetUserPins = function (Env, safeKey, channelList, cb) {
|
|
|
|
|
|
|
|
|
|
|
|
// update in-memory cache IFF the reset was allowed.
|
|
|
|
// update in-memory cache IFF the reset was allowed.
|
|
|
|
session.channels = pins;
|
|
|
|
session.channels = pins;
|
|
|
|
getHash(Env, safeKey, function (e, hash) {
|
|
|
|
cb();
|
|
|
|
cb(e, hash);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|