Rename writeAttachmentData to writeNewAttachmentData

This commit is contained in:
Daniel Gasienica 2018-04-03 21:06:29 -04:00
parent 36771a2dab
commit efd673083d
7 changed files with 28 additions and 25 deletions

View file

@ -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 }),

View file

@ -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 }
);
};