API: Fix race conditions in `setText`, `appendText`, `restoreRevision`

This commit is contained in:
Richard Hansen 2021-12-12 18:56:32 -05:00
parent cff089e54e
commit d94f380141
2 changed files with 8 additions and 12 deletions

View File

@ -13,6 +13,8 @@
* Fixed a potential attribute pool corruption bug with `copyPadWithoutHistory`.
* Mappings created by the `createGroupIfNotExistsFor` HTTP API are now removed
from the database when the group is deleted.
* Fixed race conditions in the `setText`, `appendText`, and `restoreRevision`
functions (HTTP API).
#### For plugin authors

View File

@ -201,10 +201,8 @@ exports.setText = async (padID, text) => {
// get the pad
const pad = await getPadSafe(padID, true);
await Promise.all([
pad.setText(text),
padMessageHandler.updatePadClients(pad),
]);
await pad.setText(text);
await padMessageHandler.updatePadClients(pad);
};
/**
@ -223,10 +221,8 @@ exports.appendText = async (padID, text) => {
}
const pad = await getPadSafe(padID, true);
await Promise.all([
pad.appendText(text),
padMessageHandler.updatePadClients(pad),
]);
await pad.appendText(text);
await padMessageHandler.updatePadClients(pad);
};
/**
@ -559,10 +555,8 @@ exports.restoreRevision = async (padID, rev) => {
const changeset = builder.toString();
await Promise.all([
pad.appendRevision(changeset),
padMessageHandler.updatePadClients(pad),
]);
await pad.appendRevision(changeset);
await padMessageHandler.updatePadClients(pad);
};
/**