Migration for read-only links + fix issues with read-only pads
This commit is contained in:
@@ -441,8 +441,10 @@ define([
|
||||
if (!data.href && !data.roHref) { return void cb({error:'NO_HREF'}); }
|
||||
if (!data.roHref) {
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
data.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
if (parsed.hashData.type === "pad") {
|
||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
data.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
}
|
||||
}
|
||||
var pad = makePad(data.href, data.roHref, data.title);
|
||||
if (data.owners) { pad.owners = data.owners; }
|
||||
@@ -742,7 +744,7 @@ define([
|
||||
// Edit > Edit (present) > View > View (present)
|
||||
for (var id in allPads) {
|
||||
var pad = allPads[id];
|
||||
if (!pad.href || !pad.roHref) { continue; }
|
||||
if (!pad.href && !pad.roHref) { continue; }
|
||||
|
||||
var p2 = Hash.parsePadUrl(pad.href || pad.roHref);
|
||||
var h2 = p2.hashData;
|
||||
@@ -1364,7 +1366,7 @@ define([
|
||||
}).nThen(function (waitFor) {
|
||||
Migrate(proxy, waitFor(), function (version, progress) {
|
||||
postMessage(clientId, 'LOADING_DRIVE', {
|
||||
state: 2,
|
||||
state: (2 + (version / 10)),
|
||||
progress: progress
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,11 +133,6 @@ define([
|
||||
if (!loggedIn && !config.testMode) {
|
||||
allFilesPaths.forEach(function (path) {
|
||||
var id = path[1];
|
||||
/* XXX
|
||||
var el = exp.find(path);
|
||||
if (!el) { return; }
|
||||
var id = exp.getIdFromHref(el.href);
|
||||
*/
|
||||
if (!id) { return; }
|
||||
spliceFileData(id);
|
||||
});
|
||||
@@ -256,15 +251,6 @@ define([
|
||||
};
|
||||
|
||||
// REPLACE
|
||||
/* XXX
|
||||
exp.replace = function (o, n) {
|
||||
var idO = exp.getIdFromHref(o);
|
||||
if (!idO || !exp.isFile(idO)) { return; }
|
||||
var data = exp.getFileData(idO);
|
||||
if (!data) { return; }
|
||||
data.href = n;
|
||||
};
|
||||
*/
|
||||
// If all the occurences of an href are in the trash, remove them and add the file in root.
|
||||
// This is use with setPadTitle when we open a stronger version of a deleted pad
|
||||
exp.restoreHref = function (href) {
|
||||
@@ -576,17 +562,18 @@ define([
|
||||
}
|
||||
|
||||
// If we have an edit link, check the view link
|
||||
if (el.href) {
|
||||
var fixRo = function () {
|
||||
if (el.href && parsed.hashData.type === "pad") {
|
||||
if (parsed.hashData.mode === "view") {
|
||||
el.roHref = el.href;
|
||||
delete el.href;
|
||||
} else if (!el.roHref) {
|
||||
secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||
el.roHref = '/' + parsed.type + '/#' + Hash.getViewHasFromKeys(secret);
|
||||
};
|
||||
if (!el.roHref) {
|
||||
fixRo();
|
||||
el.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
} else {
|
||||
var parsed2 = Hash.parsePadUrl(el.roHref);
|
||||
if (!parsed2.hash || !parsed2.type) {
|
||||
fixRo();
|
||||
secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||
el.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user