diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 9791e83f0..bd373b04c 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -103,7 +103,7 @@ define([ ])*/ ]) ]), - h('div.cp-version-footer', "CryptPad v3.0.1 (Aurochs' revenge)") + h('div.cp-version-footer', "CryptPad v3.1.0 (Baiji)") ]); }; diff --git a/lib/once.js b/lib/once.js index 369ee162e..a851af259 100644 --- a/lib/once.js +++ b/lib/once.js @@ -1,8 +1,7 @@ -module.exports = function (f) { - var called; +module.exports = function (f, g) { return function () { - if (called) { return; } - called = true; + if (!f) { return; } f.apply(this, Array.prototype.slice.call(arguments)); + f = g; }; }; diff --git a/package.json b/package.json index f14fda1aa..fdbbc008a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cryptpad", "description": "realtime collaborative visual editor with zero knowlege server", - "version": "3.0.1", + "version": "3.1.0", "license": "AGPL-3.0+", "repository": { "type": "git", diff --git a/rpc.js b/rpc.js index 71e267dfd..c382a275a 100644 --- a/rpc.js +++ b/rpc.js @@ -294,37 +294,33 @@ var getUploadSize = function (Env, channel, cb) { // FIXME FILES }); }; -const batchFileSize = BatchRead("GET_FILE_SIZE"); var getFileSize = function (Env, channel, cb) { if (!isValidId(channel)) { return void cb('INVALID_CHAN'); } - batchFileSize(channel, cb, function (done) { - if (channel.length === 32) { - if (typeof(Env.msgStore.getChannelSize) !== 'function') { - return done('GET_CHANNEL_SIZE_UNSUPPORTED'); - } - - return void Env.msgStore.getChannelSize(channel, function (e, size /*:number*/) { - if (e) { - if (e.code === 'ENOENT') { return void done(void 0, 0); } - return void done(e.code); - } - done(void 0, size); - }); + if (channel.length === 32) { + if (typeof(Env.msgStore.getChannelSize) !== 'function') { + return cb('GET_CHANNEL_SIZE_UNSUPPORTED'); } - // 'channel' refers to a file, so you need another API - getUploadSize(Env, channel, function (e, size) { - if (typeof(size) === 'undefined') { return void done(e); } - done(void 0, size); + return void Env.msgStore.getChannelSize(channel, function (e, size /*:number*/) { + if (e) { + if (e.code === 'ENOENT') { return void cb(void 0, 0); } + return void cb(e.code); + } + cb(void 0, size); }); + } + + // 'channel' refers to a file, so you need another API + getUploadSize(Env, channel, function (e, size) { + if (typeof(size) === 'undefined') { return void cb(e); } + cb(void 0, size); }); }; const batchMetadata = BatchRead("GET_METADATA"); var getMetadata = function (Env, channel, cb) { if (!isValidId(channel)) { return void cb('INVALID_CHAN'); } - - if (channel.length !== 32) { return cb("INVALID_CHAN"); } + if (channel.length !== 32) { return cb("INVALID_CHAN_LENGTH"); } batchMetadata(channel, cb, function (done) { var ref = {}; diff --git a/scripts/tests/test-rpc.js b/scripts/tests/test-rpc.js index 8c9f3348c..8b8c806e6 100644 --- a/scripts/tests/test-rpc.js +++ b/scripts/tests/test-rpc.js @@ -251,8 +251,7 @@ nThen(function (w) { return void console.error(err); } - // XXX validate that the write was actually successful by checking its size - + // TODO validate that the write was actually successful by checking its size response = response; // shutdown doesn't work, so we need to do this instead })); diff --git a/storage/file.js b/storage/file.js index 904e07e38..52b1d38e9 100644 --- a/storage/file.js +++ b/storage/file.js @@ -76,7 +76,7 @@ var getMetadataAtPath = function (Env, path, cb) { catch (e) { console.log("getMetadataAtPath"); console.error(e); - complete('INVALID_METADATA'); + complete('INVALID_METADATA', metadata); } }); stream.on('end', function () { diff --git a/www/common/LessLoader.js b/www/common/LessLoader.js index d9e7d3078..c04006e12 100644 --- a/www/common/LessLoader.js +++ b/www/common/LessLoader.js @@ -158,14 +158,14 @@ define([ var done = function () { clearTimeout(timeout); if (btime) { - console.log("Compiling [" + url + "] took " + (+new Date() - btime) + "ms"); + console.info("Compiling [" + url + "] took " + (+new Date() - btime) + "ms"); } cb(); }; stack.push(url); cacheGet(url, function (css) { if (css) { return void loadSubmodulesAndInject(css, url, done, stack); } - console.log('CACHE MISS ' + url); + console.debug('CACHE MISS ' + url); ((/\.less([\?\#].*)?$/.test(url)) ? loadLess : loadCSS)(url, function (err, css) { if (!css) { return void console.error(err); } var output = fixAllURLs(css, url); diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index 1210e652f..be4fa9aa2 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -728,6 +728,15 @@ define([ network.on('reconnect', function () { if (channel && channel.stopped) { return; } if (!channels[data.channel]) { return; } + + if (!joining[data.channel]) { + joining[data.channel] = function () { + console.log("reconnected to %s", data.channel); + }; + } else { + console.error("Reconnected to a chat channel (%s) which was not fully connected", data.channel); + } + network.join(data.channel).then(onOpen, function (err) { console.error(err); }); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index a64b32aa6..13783c67b 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -406,7 +406,11 @@ define([ $d.append(UI.dialog.selectable(owners, { id: 'cp-app-prop-owners', })); - if (owned) { + var parsed; + if (data.href || data.roHref) { + parsed = Hash.parsePadUrl(data.href || data.roHref); + } + if (owned && data.roHref && parsed.type !== 'drive' && parsed.hashData.type === 'pad') { var manageOwners = h('button.no-margin', Messages.owner_openModalButton); $(manageOwners).click(function () { var modal = createOwnerModal(common, data); @@ -445,7 +449,6 @@ define([ $d.append(password); } - var parsed = Hash.parsePadUrl(data.href || data.roHref); if (!data.noEditPassword && owned && parsed.hashData.type === 'pad' && parsed.type !== "sheet") { // FIXME SHEET fix password change for sheets var sframeChan = common.getSframeChannel(); var changePwTitle = Messages.properties_changePassword; @@ -590,7 +593,7 @@ define([ id: 'cp-app-prop-size', })); - if (data.sharedFolder) { + if (data.sharedFolder && false) { $('