Rename writeAttachmentData
to writeNewAttachmentData
This commit is contained in:
parent
36771a2dab
commit
efd673083d
7 changed files with 28 additions and 25 deletions
|
@ -7,15 +7,15 @@ const {
|
|||
|
||||
|
||||
// type Context :: {
|
||||
// writeAttachmentData :: ArrayBuffer -> Promise (IO Path)
|
||||
// writeNewAttachmentData :: ArrayBuffer -> Promise (IO Path)
|
||||
// }
|
||||
//
|
||||
// migrateDataToFileSystem :: Attachment ->
|
||||
// Context ->
|
||||
// Promise Attachment
|
||||
exports.migrateDataToFileSystem = async (attachment, { writeAttachmentData } = {}) => {
|
||||
if (!isFunction(writeAttachmentData)) {
|
||||
throw new TypeError('"writeAttachmentData" must be a function');
|
||||
exports.migrateDataToFileSystem = async (attachment, { writeNewAttachmentData } = {}) => {
|
||||
if (!isFunction(writeNewAttachmentData)) {
|
||||
throw new TypeError('"writeNewAttachmentData" must be a function');
|
||||
}
|
||||
|
||||
const { data } = attachment;
|
||||
|
@ -32,7 +32,7 @@ exports.migrateDataToFileSystem = async (attachment, { writeAttachmentData } = {
|
|||
` got: ${typeof attachment.data}`);
|
||||
}
|
||||
|
||||
const path = await writeAttachmentData(data);
|
||||
const path = await writeNewAttachmentData(data);
|
||||
|
||||
const attachmentWithoutData = omit(
|
||||
Object.assign({}, attachment, { path }),
|
||||
|
|
|
@ -166,13 +166,13 @@ const toVersion3 = exports._withSchemaVersion(
|
|||
);
|
||||
|
||||
// UpgradeStep
|
||||
exports.upgradeSchema = async (message, { writeAttachmentData } = {}) => {
|
||||
if (!isFunction(writeAttachmentData)) {
|
||||
throw new TypeError('`context.writeAttachmentData` is required');
|
||||
exports.upgradeSchema = async (message, { writeNewAttachmentData } = {}) => {
|
||||
if (!isFunction(writeNewAttachmentData)) {
|
||||
throw new TypeError('`context.writeNewAttachmentData` is required');
|
||||
}
|
||||
|
||||
return toVersion3(
|
||||
await toVersion2(await toVersion1(await toVersion0(message))),
|
||||
{ writeAttachmentData }
|
||||
{ writeNewAttachmentData }
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue