revert usage of batch reads for file size

pull/1/head
ansuz 5 years ago
parent 56ec91ff27
commit 40f302d002

@ -294,37 +294,33 @@ var getUploadSize = function (Env, channel, cb) { // FIXME FILES
}); });
}; };
const batchFileSize = BatchRead("GET_FILE_SIZE");
var getFileSize = function (Env, channel, cb) { var getFileSize = function (Env, channel, cb) {
if (!isValidId(channel)) { return void cb('INVALID_CHAN'); } if (!isValidId(channel)) { return void cb('INVALID_CHAN'); }
batchFileSize(channel, cb, function (done) {
if (channel.length === 32) { if (channel.length === 32) {
if (typeof(Env.msgStore.getChannelSize) !== 'function') { if (typeof(Env.msgStore.getChannelSize) !== 'function') {
return done('GET_CHANNEL_SIZE_UNSUPPORTED'); return cb('GET_CHANNEL_SIZE_UNSUPPORTED');
} }
return void Env.msgStore.getChannelSize(channel, function (e, size /*:number*/) { return void Env.msgStore.getChannelSize(channel, function (e, size /*:number*/) {
if (e) { if (e) {
if (e.code === 'ENOENT') { return void done(void 0, 0); } if (e.code === 'ENOENT') { return void cb(void 0, 0); }
return void done(e.code); return void cb(e.code);
} }
done(void 0, size); cb(void 0, size);
}); });
} }
// 'channel' refers to a file, so you need another API // 'channel' refers to a file, so you need another API
getUploadSize(Env, channel, function (e, size) { getUploadSize(Env, channel, function (e, size) {
if (typeof(size) === 'undefined') { return void done(e); } if (typeof(size) === 'undefined') { return void cb(e); }
done(void 0, size); cb(void 0, size);
});
}); });
}; };
const batchMetadata = BatchRead("GET_METADATA"); const batchMetadata = BatchRead("GET_METADATA");
var getMetadata = function (Env, channel, cb) { var getMetadata = function (Env, channel, cb) {
if (!isValidId(channel)) { return void cb('INVALID_CHAN'); } if (!isValidId(channel)) { return void cb('INVALID_CHAN'); }
if (channel.length !== 32) { return cb("INVALID_CHAN_LENGTH"); }
if (channel.length !== 32) { return cb("INVALID_CHAN"); }
batchMetadata(channel, cb, function (done) { batchMetadata(channel, cb, function (done) {
var ref = {}; var ref = {};

Loading…
Cancel
Save