mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
ImportEtherpad: Rigorously check imported data
This commit is contained in:
parent
885ff3bcde
commit
19909eae53
3 changed files with 130 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const {Pad} = require('../db/Pad');
|
||||
const authorManager = require('../db/AuthorManager');
|
||||
const db = require('../db/DB');
|
||||
const hooks = require('../../static/js/pluginfw/hooks');
|
||||
|
@ -90,6 +91,21 @@ exports.setPadRaw = async (padId, r) => {
|
|||
dbRecords.set(key, value);
|
||||
}));
|
||||
|
||||
const pad = new Pad(padId, {
|
||||
// Only fetchers are needed to check the pad's integrity.
|
||||
get: async (k) => dbRecords.get(k),
|
||||
getSub: async (k, sub) => {
|
||||
let v = dbRecords.get(k);
|
||||
for (const sk of sub) {
|
||||
if (v == null) return null;
|
||||
v = v[sk];
|
||||
}
|
||||
return v;
|
||||
},
|
||||
});
|
||||
await pad.init();
|
||||
await pad.check();
|
||||
|
||||
await Promise.all([
|
||||
...[...dbRecords].map(async ([k, v]) => await db.set(k, v)),
|
||||
...[...existingAuthors].map(async (authorId) => await authorManager.addPad(authorId, padId)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue