mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
fix(export): fix drive export issues with deleted files and office documents
This commit is contained in:
parent
8ad74abbbc
commit
484aa93d9c
@ -83,7 +83,7 @@ const factory = (Crypto, CPNetflux, Netflux, Util,
|
||||
var config = {
|
||||
websocketURL: NetConfig.getWebsocketURL(opt.origin),
|
||||
channel: secret.channel,
|
||||
validateKey: secret.keys.validateKey || undefined,
|
||||
validateKey: secret.keys?.validateKey || undefined,
|
||||
crypto: Crypto.createEncryptor(secret.keys),
|
||||
logLevel: 0,
|
||||
initialState: opt.initialState,
|
||||
|
||||
@ -195,7 +195,7 @@ define([
|
||||
|
||||
var to;
|
||||
|
||||
var done = function () {
|
||||
var done = Util.once(function () {
|
||||
if (ctx.stop) { return; }
|
||||
if (to) { clearTimeout(to); }
|
||||
//setTimeout(g, 2000);
|
||||
@ -203,7 +203,7 @@ define([
|
||||
ctx.updateProgress('download', {max: ctx.max, current: ctx.done});
|
||||
g();
|
||||
w();
|
||||
};
|
||||
});
|
||||
|
||||
var error = function (err) {
|
||||
if (ctx.stop) { return; }
|
||||
@ -248,12 +248,13 @@ define([
|
||||
};
|
||||
transform(ctx, parsed.type, val, function (res) {
|
||||
if (ctx.stop) { return; }
|
||||
if (res.error) { return void error(err); }
|
||||
if (!res.data) { return void error('EEMPTY'); }
|
||||
var fileName = getUnique(sanitize(rawName), res.ext, existingNames);
|
||||
existingNames.push(fileName.toLowerCase());
|
||||
zip.file(fileName, res.data, opts);
|
||||
console.log('DONE ---- ' + fileName);
|
||||
setTimeout(done, 500);
|
||||
setTimeout(done, 1);
|
||||
}, {
|
||||
hash: parsed.hash,
|
||||
password: fData.password
|
||||
@ -277,7 +278,7 @@ define([
|
||||
existingNames.push(fileName.toLowerCase());
|
||||
zip.file(fileName, res.content, opts);
|
||||
console.log('DONE ---- ' + fileName);
|
||||
setTimeout(done, 1000);
|
||||
setTimeout(done, 1);
|
||||
});
|
||||
it = setInterval(function () {
|
||||
if (ctx.stop) {
|
||||
@ -295,7 +296,7 @@ define([
|
||||
var content = new Blob([fData.href, '\n'], { type: "text/plain;charset=utf-8" });
|
||||
zip.file(fileName, content, opts);
|
||||
console.log('DONE ---- ' + fileName);
|
||||
setTimeout(done, 1000);
|
||||
setTimeout(done, 1);
|
||||
};
|
||||
if (parsed.hashData.type === 'file') {
|
||||
return void todoFile();
|
||||
@ -344,7 +345,7 @@ define([
|
||||
// Main function. Create the empty zip and fill it starting from drive.root
|
||||
var create = function (data, getPad, fileHost, cb, progress, cache, sframeChan) {
|
||||
if (!data || !data.uo || !data.uo.drive) { return void cb('EEMPTY'); }
|
||||
var sem = Saferphore.create(5);
|
||||
var sem = Saferphore.create(1);
|
||||
var ctx = {
|
||||
fileHost: fileHost,
|
||||
get: getPad,
|
||||
@ -481,7 +482,6 @@ define([
|
||||
var addErrors = function(errs) {
|
||||
if (!errs.length) { return; }
|
||||
var onClick = function() {
|
||||
console.error('clicked?');
|
||||
$(errors).toggle();
|
||||
};
|
||||
$(error).click(onClick).appendTo(actions);
|
||||
|
||||
@ -851,13 +851,22 @@ define([
|
||||
|
||||
if (!exists) { return void UI.removeLoadingScreen(); }
|
||||
|
||||
let todo = ({blob, file, fileType}) => {
|
||||
ooChannel.queue = messages.slice(1, minor+1);
|
||||
resetData(blob, file || fileType);
|
||||
UI.removeLoadingScreen();
|
||||
};
|
||||
if (!cp?.file) {
|
||||
return loadDocument(true, true, void 0, todo);
|
||||
}
|
||||
loadLastDocument(cp)
|
||||
.then(({blob, fileType}) => {
|
||||
ooChannel.queue = messages.slice(1, minor+1);
|
||||
resetData(blob, fileType);
|
||||
UI.removeLoadingScreen();
|
||||
})
|
||||
.catch(() => {
|
||||
.then(todo)
|
||||
.catch((err) => {
|
||||
if (APP.isDownload) {
|
||||
return void sframeChan.event('EV_OOIFRAME_DONE', {
|
||||
error: 'INVALID'
|
||||
});
|
||||
}
|
||||
if (cp.hash && vHashEl) {
|
||||
// We requested a checkpoint but we can't find it...
|
||||
UI.removeLoadingScreen();
|
||||
@ -3147,6 +3156,11 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||
}
|
||||
content = json.content;
|
||||
readOnly = true;
|
||||
if (!content.version || content.version <= 7) {
|
||||
return void sframeChan.event('EV_OOIFRAME_DONE', {
|
||||
error: 'MIGRATE'
|
||||
});
|
||||
}
|
||||
var version = (!content.version || content.version === 1) ? 'v1/' :
|
||||
(content.version <= 3 ? 'v2b/' : OOCurrentVersion.currentVersion + '/');
|
||||
var s = h('script', {
|
||||
@ -3164,6 +3178,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||
// minor version of 0. "openVersionHash" knows that it needs to give us the latest
|
||||
// version when "APP.isDownload" is true.
|
||||
var sheetVersion = lastIndex + '.0';
|
||||
ooLoaded = false;
|
||||
openVersionHash(sheetVersion);
|
||||
});
|
||||
|
||||
|
||||
@ -12,27 +12,34 @@ define([
|
||||
], function (nThen, ApiConfig, $, RequireConfig, Messages) {
|
||||
var requireConfig = RequireConfig();
|
||||
|
||||
var ready = false;
|
||||
var currentCb;
|
||||
var queue = [];
|
||||
//var ready = false;
|
||||
const state = {};
|
||||
['doc', 'sheet', 'presentation'].forEach(app => {
|
||||
state[app] = {
|
||||
ready: false,
|
||||
queue: [],
|
||||
cb: undefined
|
||||
};
|
||||
});
|
||||
|
||||
var create = function (config) {
|
||||
const s = state[config.type];
|
||||
// Loaded in load #2
|
||||
var sframeChan;
|
||||
var Util = config.modules.Utils.Util;
|
||||
var _onReadyEvt = Util.mkEvent(true);
|
||||
var refresh = function (data, cb) {
|
||||
if (currentCb) {
|
||||
queue.push({data: data, cb: cb});
|
||||
if (s.cb) {
|
||||
s.queue.push({data: data, cb: cb});
|
||||
return;
|
||||
}
|
||||
if (!ready) {
|
||||
if (!s.ready) {
|
||||
_onReadyEvt.reg(function () {
|
||||
refresh(data, cb);
|
||||
});
|
||||
return;
|
||||
}
|
||||
currentCb = cb;
|
||||
s.cb = cb;
|
||||
sframeChan.event('EV_OOIFRAME_REFRESH', data);
|
||||
};
|
||||
nThen(function (waitFor) {
|
||||
@ -50,8 +57,8 @@ define([
|
||||
};
|
||||
window.rc = requireConfig;
|
||||
window.apiconf = ApiConfig;
|
||||
$('#sbox-oo-iframe').attr('src',
|
||||
ApiConfig.httpSafeOrigin + '/sheet/inner.html?' + requireConfig.urlArgs +
|
||||
$(`#sbox-oo-iframe-${config.type}`).attr('src',
|
||||
ApiConfig.httpSafeOrigin + `/${config.type}/inner.html?` + requireConfig.urlArgs +
|
||||
'#' + encodeURIComponent(JSON.stringify(req)));
|
||||
|
||||
// This is a cheap trick to avoid loading sframe-channel in parallel with the
|
||||
@ -76,7 +83,7 @@ define([
|
||||
// First, we have to answer to this message, otherwise we're going to block
|
||||
// sframe-boot.js. Then we can start the channel.
|
||||
var msgEv = Utils.Util.mkEvent();
|
||||
var iframe = $('#sbox-oo-iframe')[0].contentWindow;
|
||||
var iframe = $(`#sbox-oo-iframe-${config.type}`)[0].contentWindow;
|
||||
var postMsg = function (data) {
|
||||
iframe.postMessage(data, '*');
|
||||
};
|
||||
@ -122,6 +129,7 @@ define([
|
||||
pathname: window.location.pathname,
|
||||
feedbackAllowed: Utils.Feedback.state,
|
||||
secureIframe: true,
|
||||
ooType: config.type,
|
||||
supportsWasm: Utils.Util.supportsWasm()
|
||||
};
|
||||
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }
|
||||
@ -139,15 +147,15 @@ define([
|
||||
});
|
||||
|
||||
sframeChan.on('EV_OOIFRAME_DONE', function (data) {
|
||||
if (queue.length) {
|
||||
if (s.queue.length) {
|
||||
setTimeout(function () {
|
||||
var first = queue.shift();
|
||||
var first = s.queue.shift();
|
||||
refresh(first.data, first.cb);
|
||||
});
|
||||
}
|
||||
if (!currentCb) { return; }
|
||||
currentCb(data);
|
||||
currentCb = undefined;
|
||||
if (!s.cb) { return; }
|
||||
s.cb(data);
|
||||
s.cb = undefined;
|
||||
});
|
||||
|
||||
// X2T
|
||||
@ -157,8 +165,8 @@ define([
|
||||
});
|
||||
|
||||
sframeChan.onReady(function () {
|
||||
if (ready === true) { return; }
|
||||
ready = true;
|
||||
if (s.ready) { return; }
|
||||
s.ready = true;
|
||||
_onReadyEvt.fire();
|
||||
});
|
||||
});
|
||||
|
||||
@ -230,7 +230,7 @@ define([
|
||||
};
|
||||
|
||||
var convert = function (obj, cb) {
|
||||
console.error(obj);
|
||||
//console.error(obj);
|
||||
obj.fileName = sanitize(obj.fileName);
|
||||
getX2T(function (x2t) {
|
||||
// Fonts
|
||||
|
||||
@ -1910,7 +1910,7 @@ define([
|
||||
UnsafeObject.$iframe = $('<iframe>', {
|
||||
id: 'sbox-unsafe-iframe',
|
||||
allow: 'clipboard-write'
|
||||
}).appendTo($('body')).hide();
|
||||
}).appendTo($('body'));//.hide();
|
||||
UnsafeObject.modal = UnsafeIframe.create(config);
|
||||
}
|
||||
UnsafeObject.modal.refresh(cfg, function (data) {
|
||||
@ -1922,21 +1922,24 @@ define([
|
||||
// OO iframe
|
||||
var OOIframeObject = {};
|
||||
var initOOIframe = function (cfg, cb) {
|
||||
if (!OOIframeObject.$iframe) {
|
||||
const app = cfg.type;
|
||||
if (!OOIframeObject[app]?.$iframe) {
|
||||
const obj = OOIframeObject[app] ||= {};
|
||||
var config = {};
|
||||
config.type = app;
|
||||
config.addCommonRpc = addCommonRpc;
|
||||
config.modules = {
|
||||
Cryptpad: Cryptpad,
|
||||
SFrameChannel: SFrameChannel,
|
||||
Utils: Utils
|
||||
};
|
||||
OOIframeObject.$iframe = $('<iframe>', {
|
||||
id: 'sbox-oo-iframe',
|
||||
obj.$iframe = $('<iframe>', {
|
||||
id: `sbox-oo-iframe-${app}`,
|
||||
allow: 'clipboard-write'
|
||||
}).appendTo($('body')).hide();
|
||||
OOIframeObject.modal = OOIframe.create(config);
|
||||
}).appendTo($('body'));//.hide();
|
||||
obj.modal = OOIframe.create(config);
|
||||
}
|
||||
OOIframeObject.modal.refresh(cfg, function (data) {
|
||||
OOIframeObject[app]?.modal?.refresh(cfg, function (data) {
|
||||
cb(data);
|
||||
});
|
||||
};
|
||||
@ -2090,18 +2093,24 @@ define([
|
||||
// so that we can disconnect the network
|
||||
cgNetworkStatus[cgNetworkId] ||= [];
|
||||
cgNetworkStatus[cgNetworkId].push(new Promise((res) => {
|
||||
Cryptget.get(data.hash, function (err, val) {
|
||||
try {
|
||||
Cryptget.get(data.hash, function (err, val) {
|
||||
res(network);
|
||||
cb({
|
||||
error: err,
|
||||
data: val
|
||||
});
|
||||
}, data.opts, function (progress) {
|
||||
sframeChan.event("EV_CRYPTGET_PROGRESS", {
|
||||
hash: data.hash,
|
||||
progress: progress,
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
res(network);
|
||||
cb({
|
||||
error: err,
|
||||
data: val
|
||||
});
|
||||
}, data.opts, function (progress) {
|
||||
sframeChan.event("EV_CRYPTGET_PROGRESS", {
|
||||
hash: data.hash,
|
||||
progress: progress,
|
||||
});
|
||||
});
|
||||
console.error(data.hash, e, data);
|
||||
cb({error: 'EINVAL'});
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
2
www/common/worker.bundle.min.js
vendored
2
www/common/worker.bundle.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user